Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 179382 - dhcpcd-3.1-pre1 (svn version) bug
Summary: dhcpcd-3.1-pre1 (svn version) bug
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-22 05:32 UTC by Stanislav Ievlev
Modified: 2007-06-29 09:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Ievlev 2007-05-22 05:32:07 UTC
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.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2007-05-22 12:52:57 UTC
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.
Comment 2 Stanislav Ievlev 2007-05-23 13:45:15 UTC
hostname usually means FQDN (e.g. in RedHat-derived distros)

Comment 3 Roy Marples (RETIRED) gentoo-dev 2007-05-23 14:08:26 UTC
(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.
Comment 4 Roy Marples (RETIRED) gentoo-dev 2007-05-23 14:49:11 UTC
svn repo updated, stripped out the above code.
Comment 5 Roy Marples (RETIRED) gentoo-dev 2007-05-25 12:23:57 UTC
(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?
Comment 6 Stanislav Ievlev 2007-05-28 07:13:14 UTC
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 ;)
Comment 7 Roy Marples (RETIRED) gentoo-dev 2007-05-28 08:33:08 UTC
(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?
Comment 8 Stanislav Ievlev 2007-05-29 06:27:50 UTC
(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.




Comment 9 Roy Marples (RETIRED) gentoo-dev 2007-05-30 09:35:23 UTC
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?
Comment 10 Stanislav Ievlev 2007-05-30 15:04:11 UTC
yes
Comment 11 Roy Marples (RETIRED) gentoo-dev 2007-06-29 09:30:29 UTC
Well, it's hardly fixed as 3.1 isn't in the tree yet, but I'm closing this anyway.