Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong networking.fqdn in the presence of search . in /etc/resolv.conf #2693

Closed
Geod24 opened this issue Mar 23, 2024 · 1 comment · Fixed by #2694
Closed

Wrong networking.fqdn in the presence of search . in /etc/resolv.conf #2693

Geod24 opened this issue Mar 23, 2024 · 1 comment · Fixed by #2694
Labels
bug Something isn't working triaged Jira issue has been created for this

Comments

@Geod24
Copy link
Contributor

Geod24 commented Mar 23, 2024

Describe the Bug

$ /opt/puppetlabs/bin/facter networking
{
  dhcp => "xxx.xxx.xxx.xxx",
  domain => ".",
  fqdn => "xxx-xxx-prd-vm03..",
  hostname => "xxx-xxx-prd-vm03",
  [...]

This happens because:

$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 37 Mar 23 10:47 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf
$ cat /run/systemd/resolve/stub-resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search .

Commenting out the search entry fixes the issue. This happens because this machine is configured without a domain, but with a search path, leading to this being executed:
https://github.com/puppetlabs/facter/blame/7bfd75b1c76bb5d531c35131b717fb0697a54426/lib/facter/resolvers/linux/hostname.rb#L101-L103

And then a wrong concatenation:
https://github.com/puppetlabs/facter/blame/7bfd75b1c76bb5d531c35131b717fb0697a54426/lib/facter/resolvers/linux/hostname.rb#L110

Expected Behavior

facter should not read search in the first place. search is a client lookup option, and it is not intended to set the machine's hostname.

Steps to Reproduce

See resolv.conf configuration above. Make sure the machine has no domain configured.

Environment

# /opt/puppetlabs/bin/facter --version
4.6.1
 # uname -a
Linux xxx-xxx-prd-vm03 5.10.0-22-amd64 #1 SMP Debian 5.10.178-3 (2023-04-22) x86_64 GNU/Linux

Additional Context

Introduced in: #2296
CC @oanatmaria : I know it's been a while since you've made this contribution, but I couldn't find the reason that facter is reading search. Could you shed some light on this ?
EDIT: Tracking the git history seems to point to it being there since a long time, e.g. 0599a60

@Geod24 Geod24 added the bug Something isn't working label Mar 23, 2024
@cthorn42 cthorn42 added the triaged Jira issue has been created for this label Mar 26, 2024
Copy link

Migrated issue to FACT-3459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Jira issue has been created for this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants