OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Incorrect domainname

From: Wietse Venema (wietseporcupine.org)
Date: Mon Dec 03 2007 - 09:05:46 CST


Paul Hewlett:
> On Monday 03 December 2007 16:16:05 Wietse Venema wrote:
> > Paul Hewlett:
> > > I recently upgraded from 2.3.6 to 2.4.5 on my Gentoo master box and
> > > postfix is now unable to get the domainname - it insists that it is
> > > 'localdomain'.
> > >
>
> > Postfix uses the gethostname() system library routine. What is the
> > result from that function?
> >
> > If the result from gethostname() is a fully qualified name
> > ("sundown.cpt.gccs.co.za") then Postfix will use that to derive
> > the mydomain value ("cpt.gccs.co.za");
> >
> > If the result from gethostname() is an unqualified name ("sundown")
> > then Postfix sets mydomain to "localdomain" unless you specify
> > mydomain or myhostname in main.cf.
> >
> > Wietse
>
> Wietse
>
> I downgraded to 2.3.6 and mail is now sent successfully using the same config
> files.
>
> /var/log/messages shows:
> Dec 3 16:51:36 sundown postfix/qmgr[24971]: 1F736737D4C:
> from=<rootsundown.cpt.gccs.co.za>, size=596, nrcpt=1 (queue active)
> Dec 3 16:51:36 sundown postfix/smtp[24977]: 1F736737D4C:
> to=<supportcpt.gccs.co.za>, orig_to=<root>,
> relay=smtp.cpt.gccs.co.za[192.168.169.1]:25, delay=0.01, delays=0.01/0/0/0,
> dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 1D48018E142)
>
> As you can see $mydomain is now 'cpt.gccs.co.za' and the mail is now sent
> correctly. It's a bug in 2.4.5 and beyond.

Would it be possible to actually answer my question?

$ cat >x.c
#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("%.*s\n", MAXNAME, namebuf);
    exit(0);
}
$ make x
$ ./x

What is the output from the last command?

        Wietse