Bug 2038634 - Full hostname does not include domain when nss-myhostame is in use
Summary: Full hostname does not include domain when nss-myhostame is in use
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 35
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-09 05:30 UTC by Ian Dall
Modified: 2022-10-04 04:10 UTC (History)
11 users (show)

Fixed In Version: systemd-250.6-1.fc36
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-27 01:09:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd systemd issues 22081 0 None open Full hostname does not include domain when nss-myhostame is in use 2022-01-11 06:12:10 UTC

Description Ian Dall 2022-01-09 05:30:31 UTC
Description of problem:
hostname -f returns <host> not <host>.<domain>

Version-Release number of selected component (if applicable):

systemd-libs-249.7-2.fc35.x86_64

How reproducible:

Always

Steps to Reproduce:
1. configure host line in nsswitch.conf to 
hosts: resolve [!UNAVAIL=return] files myhostname dns
2. hostnamectl --transient $(hostname -s) 
3. systemctl stop systemd-resolved
4. hostname -f

Actual results:

<host>

Expected results:

<host>.<domain>

Additional info:

Step 2 obviously does not include the domain name in the transient hostname. This is, apparently, what happens with dhcp network configuration and I would argue it is correct. Even though hostnamectl permits hostname to be set to a fqdn, linux has a limit of 64 characters, which is compatible with a DNS label limit of 63 characters, but not with a DNS fqdn limit of 253 characters.

nss-myhostname it seems, is trying to replace (dynamically) what would have traditionally be done via /etc/hosts, where the standard recommendation was to have the canonical name (fqdn) first with aliases after.

I think nss-myhostname should be appending the domain name when it looks up the interface addresses. This should be the first search domain in /etc/resolv.conf if it exists.

The hostname specification seems to be weakly standardized in the unix world, yet it needs to be consistent, at least on one installation. For example, readonly-root can use the hostname to specify a statefile held on an nfs server.  Currently, with the above configuration, hostname -f returns different results depending on whether systemd-resolved is running or not.

The above ordering in nsswitch.conf is consistent with the nss-myhostname(8) man page. The man page does contain a caveat regarding reverse resolution and a work around is to place 'myhostname' after 'dns' but this may not work if the real name server is not available (untested).

Comment 1 Fedora Update System 2022-05-25 20:10:52 UTC
FEDORA-2022-3ca356cd2e has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-3ca356cd2e

Comment 2 Fedora Update System 2022-05-26 02:32:45 UTC
FEDORA-2022-3ca356cd2e has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-3ca356cd2e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-3ca356cd2e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Fedora Update System 2022-05-27 01:09:59 UTC
FEDORA-2022-3ca356cd2e has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.