Hostname incorrectly configured was - Re: Postfix/Network config out of the box
Scott Kitterman
ubuntu at kitterman.com
Wed Jul 19 03:20:55 UTC 2006
On Tuesday 18 July 2006 13:33, Scott Kitterman wrote:
> On Tue, 18 Jul 2006 11:28:56 -0500 "Christofer C. Bell"
>
> >I can't help but feel I'm being misunderstood. My machine is on a
> >static public IP address. I used the Networking control panel to
> >configure it. The Networking control panel improperly formats the
> >/etc/hosts file causing the /etc/postfix/main.cf file to inherit an
> >incorrect setting (at least as far as I can tell).
>
> OK. The only Ubuntu box I have that has a hosts file like yours is on
> DHCP. looks like I made an incorrect leap of judgement. Sorry about that.
>
> I'll see if I can investigate this further tomorrow.
>
> Scott K
OK. I agree you found a bug and you may even have found a general workaround
for it, but it's broader than just Postfix.
I may well have manually made changes on my servers that I forgot about.
From Postconf 5:
http://www.postfix.org/postconf.5.html#myhostname
"The default is to use the fully-qualified domain name from gethostname."
So, Postfix is expecting the standard C function gethostname to produce a
FQDN. I decided to test this. First by removing myhostname from main.cf and
then by accessing the C function as directly as I could. Fortunately, Python
gives almost direct access to this function in its socket module:
http://www.python.org/doc/2.4.3/lib/module-socket.html
So, through Python, I call the same function (this is on an Ubuntu server):
mailout00:~$ python
Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> print socket.gethostname()
mailout00
Just the machine name, not a FQDN.
Here is the same thing on a FreeBSD 4.8-STABLE machine:
raung% python
Python 2.4.1 (#1, Jun 10 2005, 16:38:07)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> print socket.gethostname()
raung.pair.com
Just to make sure, Python also has another function called getfqdn.
Ubuntu:
mailout00:~$ python
Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> print socket.getfqdn()
mailout00
FreeBSD:
raung% python
Python 2.4.1 (#1, Jun 10 2005, 16:38:07)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> print socket.getfqdn()
raung.pair.com
I think that's reasonably conclusive. Ubuntu and FreeBSD are all I have easy
access to at the moment. I searched launchpad and found a number of closely
related bugs:
https://launchpad.net/distros/ubuntu/+source/netcfg/+bug/8980
https://launchpad.net/distros/ubuntu/+source/netcfg/+bug/11019
https://launchpad.net/distros/ubuntu/+source/netcfg/+bug/23714
I'm not sure if this should get piled onto one of those or be a new one. You
found it, so I think you should have the first shot at reporting it.
Sorry it took me so long to come around.
Scott K
More information about the ubuntu-users
mailing list