Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 199946

Summary: Gentoo is returning the wrong value for getdomainname
Product: Gentoo Linux Reporter: Luke-Jr <luke-jr+gentoobugs>
Component: [OLD] ServerAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED INVALID    
Severity: normal CC: base-system, gengor, gentoo, paul
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Luke-Jr 2007-11-22 06:04:18 UTC
For whatever reason, someone rewrote 'get_hostname' in Postfix 2.4. This new one does not work correctly and treats every hostname as local. Instead of the correct result of 'linux-1.dombr.org' (as with Postfix 2.3), 2.4 is making up 'linux-1.localdomain' and getting confused, rejecting and dropping mail in the meantime. This is quite definately an upstream problem, but I couldn't find an upstream bug tracker.
Comment 1 Luke-Jr 2007-11-22 06:19:59 UTC
linux-1 etc # postconf -c /tmp/empty myhostname
myhostname = linux-1.localdomain
linux-1 etc # hostname -f
linux-1.dombr.org
Comment 2 Paul Hewlett 2007-11-27 14:03:00 UTC
(In reply to comment #1)
> linux-1 etc # postconf -c /tmp/empty myhostname
> myhostname = linux-1.localdomain
> linux-1 etc # hostname -f
> linux-1.dombr.org
> 
I have the same problem - suddenly all my mail is rejected because the sender address has 'localdomain' instead of my actual domain. I temporarily fixed by setting myhostname,mydomain and mydestination explicitly
Comment 3 Paul Hewlett 2007-12-03 16:00:06 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > linux-1 etc # postconf -c /tmp/empty myhostname
> > myhostname = linux-1.localdomain
> > linux-1 etc # hostname -f
> > linux-1.dombr.org
> > 
> I have the same problem - suddenly all my mail is rejected because the sender
> address has 'localdomain' instead of my actual domain. I temporarily fixed by
> setting myhostname,mydomain and mydestination explicitly

I joined the postfix mailing list and asked for help. Postfix uses the gethostname/getdomainname calls to get the necessary values. On gentoo the getdomainname call always returns (none). For some reason, postfix 2.3.6 handles this correctly but postfix 2.4.5 does not.

I see that one can now specify the domainname by adding dns_domain_lo="..." to the file /etc/conf.d/net but that did not work.
Comment 4 Paul Hewlett 2007-12-04 07:42:03 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)

> I see that one can now specify the domainname by adding dns_domain_lo="..." to
> the file /etc/conf.d/net but that did not work.
> 

I have enquired on the postfix mailing list about this and run the following program:

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#define MAXNAME 1024

int     main(void)
{
    char    namebuf[MAXNAME];

    if (gethostname(namebuf, sizeof(namebuf)) != 0)
        perror("gethostname");
    else
        printf("hostname=%.*s\n", MAXNAME, namebuf);

    if (getdomainname(namebuf, sizeof(namebuf)) != 0)
        perror("getdomainname");
    else
        printf("Domain=%.*s\n", MAXNAME, namebuf);

    exit(0);
}

No matter what combinations of settings in gentoo the getdomainname() call always returns (none).
The settings I tried were the /etc/hosts entry:
127.0.0.1 hostname.domainname hostname localhost

and in /etc/conf.d/net:
dns_domain_lo="domainname"

and in /etc/conf.d/hostname:
hostname="hostname.domainname"

In all cases getdomainname returns (none). In the last case, postfix 2.4.5 did work as expected - however the hostname command then returns the FQDN instead of hostname -f and I am unsure of the ramifications of this.

The postfix developers are adamant that postfix is now right and gentoo is incorrect - in the meantime I am downgrading to 2.3.6
Comment 5 Paul Hewlett 2007-12-05 10:35:05 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > (In reply to comment #1)

> The postfix developers are adamant that postfix is now right and gentoo is
> incorrect - in the meantime I am downgrading to 2.3.6
> 
This is my last post on this 
Careful reading of this link 
http://www.gnu.org/software/libc/manual/html_node/Host-Identification.html#Host-Identification

indicates that the way gentoo sets the host name is incorrect. I modified the
file
/etc/conf.d/hostname to set a new variable FQDN to the canonical hostname

FQDN="hostname.domain"

and then modified /etc/init.d/hostname to do:

HOSTNAME=$( echo ${FQDN} | cut -d'.' -f1 )
hostname ${FQDN}

postfix then worked. The only other change I have made is to remove '.\O' from the /etc/issue file. Everything else appears to work.

The getdomainname problems in previous comments is a red herring.
Comment 6 Luke-Jr 2007-12-05 10:47:57 UTC
How do you figure? Everything in that link defines "hostname" as the FQDN and defines getdomainname to be (unused, for most people) NIS/YP stuff.
Comment 7 Luke-Jr 2007-12-05 10:50:44 UTC
"host name", that is
Comment 8 Paul Hewlett 2007-12-05 11:15:29 UTC
(In reply to comment #7)
> "host name", that is
> 
Ah yes - the gentoo installation instructions have the file /etc/conf.d/hostname as:

HOSTNAME="myhostname"

and the script /etc/init.d/hostname executes:

hostname ${HOSTNAME}

which is not the canonical FQDN. 
Comment 9 Luke-Jr 2007-12-05 11:33:38 UTC
Ok, now it makes sense :)
Basically, the problem then is that Gentoo makes the FQDN second-class... :/
Comment 10 Raphael Marichez (Falco) (RETIRED) gentoo-dev 2008-03-21 17:02:35 UTC
Hi,

from what i understand, the Gentoo ebuild has nothing to do with it. Postfix 2.4 release notes warn about that changing behaviour:

Major changes - small office/home office support 
------------------------------------------------ 
 
[Incompat 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. 



Viktor from the postfix ML said:
" you are (finally) seeing a correctly behaving Postfix, no longer
broken by misguided patches. On systems whose hostname is not an fqdn,
the main.cf file must contain an explicit "mydomain" setting unless
"localdomain" is acceptable (systems lacking a proper FQDN)."

so, "not a bug but a feature" (tm)

And :
On Wed, Dec 05, 2007 at 12:39:12PM +0200, Paul Hewlett wrote:
> Just a quick note of thanks for the help from you and others.
> I now set my hostname to the canonical FQDN on my gentoo boxes .
> This , of course, contradicts the standard described in the gentoo 
> installation instructions.

Viktor answered:
"You don't have to do that. You can instead set "mydomain = ..." in
main.cf. Mail systems need a stable domain because user email addresses
must not change randomly when a dynamically addressed system gets a new
name from DHCP. The "localdomain" approach is quite sensible for most
end-systems."

So you have several solutions in your hands, now.
Comment 11 Luke-Jr 2008-03-21 18:21:58 UTC
Correct, it is not a problem with the ebuild. This bug is still a bug in Gentoo though, as long as Gentoo is returning the wrong value for getdomainname
Comment 12 Tobias Scherbaum (RETIRED) gentoo-dev 2009-01-04 18:42:13 UTC
Re-assigning to toolchain@ as glibc provides getdomainname, also CC'ing base-system@ ... whoever might be interested in that bug.
Comment 13 SpanKY gentoo-dev 2009-01-04 20:38:58 UTC
the behavior of glibc looks correct to me.  i think you're confusing DNS behavior with non-DNS behavior.  `hostname` and `domainname` do not set DNS info, just like gethostname() and getdomainname() do not return DNS info.

whatever you give to `hostname` is taken straight without parsing.  that is because it isnt a DNS name.

the test case in Comment #4 works fine for me after correctly using the programs in question:
# hostname vapier
# domainname wh0rd.org
# ./a.out
hostname=vapier
Domain=wh0rd.org