dhcpcd from svn (3.1-pre1) contains a strange resolving code: -- ... } else if (*addr) { /* Strip out the domain if it matches */ char *p = addr; char *token = strsep (&p, "."); bool match_domain = false; if (p && *p) { if (dhcp->dnssearch) { char *s = xstrdup (dhcp->dnssearch); char *sp = s; char *t; while ((t = strsep (&sp, " "))) if (strcmp (t, p) == 0) { match_domain = true; break; } free (s); } else if (dhcp->dnsdomain) { if (strcmp (dhcp->dnsdomain, p) == 0) match_domain = true; } } if (match_domain) strlcpy (newhostname, token, sizeof (newhostname)); else snprintf (newhostname, sizeof (newhostname), "%s.%s", token, p); } } -- It's a bad idea to strip domainname from hostname. As a result of this code I will have a hostname 'test' instead of 'test.domain', and therefore, some programs (e.g. postfix) will not work. It's better to replace this algo with a simple copying addr to newhostname variable. Reproducible: Always Steps to Reproduce: 1. dhcpcd -H interface Actual Results: $hostname test Expected Results: $hostname test.domain It's possible a gentoo specific behaviour, but other distros can preffer fully qualified domain names.
If the hostname is test.home.com and the domain is home.com then the FQDN would be test.home.com.home.com, which is bad. If the domain is NOT given via DHCP then the hostname is set to test.home.com and the FQDN would be test.home.com. >It's possible a gentoo specific behaviour, but other distros can preffer fully >qualified domain names. Hmmm? Only dhcpcd and pump look up the hostname in DNS and use that. Most distros use dhclient from ISC's dhcp package which doesn't lookup in DNS (and therefore doesn't have this issue). pump also strips the domain out, and now dhcpcd does this too.
hostname usually means FQDN (e.g. in RedHat-derived distros)
(In reply to comment #2) > hostname usually means FQDN (e.g. in RedHat-derived distros) Gentoo and dhcpcd are in no way RedHat derived :) And no RedHat DHCP clients that I know can lookup the hostname in DNS and set the local hostname to that. Also, the hostname could go either way really. It makes no real difference. If it does, then any "broken" programs need to be fixed. One issue is that getty uses \n in issue, so it look's a little weird on boot.
svn repo updated, stripped out the above code.
(In reply to comment #0) > It's a bad idea to strip domainname from hostname. > As a result of this code I will have a hostname 'test' instead of > 'test.domain', and therefore, some programs (e.g. postfix) will not work. Are you referring to this? Incompatible changes with Postfix snapshot 20061217 =================================================== Postfix no longer requires a domain name. It uses "localdomain" as the default Internet domain name when no domain is specified via main.cf or via the machine's hostname. As I'm probably going to put that code back as it makes sense. Remember that postfix can handle mail for than one domain. Maybe we could add it as an extra option? dhcpcd -H just sets the hostname bit if the domain matches part of the dns name dhcpcd -HH always sets the full dns name Would that be acceptable?
And what about all previous Postfix installations? And what about other applications? You should preffer backward compatibility with existing software. Please, don't change behaviour of the -H option ;)
(In reply to comment #6) > And what about all previous Postfix installations? > And what about other applications? > You should preffer backward compatibility with existing software. Right, and this is not being broken. How hostname and dnsdomain are setup now by dhcpcd mirrors how hostname and domainname are setup in Gentoo without dhcpcd - by default. > Please, don't change behaviour of the -H option ;) Is -HH such a hard thing to do?
(In reply to comment #7) > (In reply to comment #6) > > And what about all previous Postfix installations? > > And what about other applications? > > You should preffer backward compatibility with existing software. > > Right, and this is not being broken. > How hostname and dnsdomain are setup now by dhcpcd mirrors how hostname and > domainname are setup in Gentoo without dhcpcd - by default. dhcpcd was not Gentoo only application ;) > > > Please, don't change behaviour of the -H option ;) > > Is -HH such a hard thing to do? We have a lot of installations with "-H" options in config. It's will be a bad surprise for users to have a new hostname after dist-upgrade. If you will change -H behaviour we will have always patch your application to resurrect previous behaviour or -H.
Fair enough. New dhcpcd options to hopefully please everyone. From the updated man page. -H Forces dhcpcd to set hostname of the host to the hostname option supplied by DHCP server. By default dhcpcd will NOT set hostname of the host to the hostname option received from DHCP server unless the current hostname is blank, (none) or localhost. If no hostname is returned by the DHCP server then we attempt to lookup the hostname via DNS. More -H's control what we do with the FQDN returned by DNS. -H set hostname to the full FQDN -HH strip the domain if it matches a given domain in our DHCP message -HHH strip the domain regardless -HHHH force hostname lookup even if given a hostname in our DHCP message -HHHHH same as above, but strip the domain if it matches -HHHHHH same as above, but strip the domain regardless Does this satisfy your needs?
yes
Well, it's hardly fixed as 3.1 isn't in the tree yet, but I'm closing this anyway.