Bug#319946: perl-modules: Net::Domain::hostfqdn() returns an incorrect FQDN

Vincent Lefevre vincent at vinc17.net
Fri Sep 30 13:57:44 UTC 2016


Control: found -1 5.24.1~rc3-3

On 2006-07-14 22:58:30 +0200, markus koller wrote:
> I was able to solve my problem by putting only the hostname in
> /etc/hostname (just 'snafu' instead of 'snafu.selfip.org').
> hostfqdn() now returns the correct domain.
> 
> A little googling revealed that there's no clear rule whether
> /etc/hostname should contain only the short name or the FQDN, so I
> think perl should work with both, especially as the other commands
> and languages also managed to return the right FQDN.

It seems that putting the short name is the common rule nowadays
(not sure), at least in Debian, but yes, since this is not
mandatory, perl should work with both.

Anyway, even with the short name, it is broken.
Test with 5.24.1~rc3-3:

cventin:~> perl -e 'use Net::Domain qw(hostfqdn); print hostfqdn()."\n"'
cventin.lip.ens-lyon.fr.

Notice the trailing dot. I suspect that it comes from the "search"
line in:

cventin:~> cat /etc/resolv.conf
# Generated by NetworkManager
search lip.ens-lyon.fr. ens-lyon.fr.
nameserver 140.77.1.32
nameserver 140.77.167.2

And actually, using the "search" line here is wrong because
/etc/hosts has the precedence with the standard resolver, as
specified by my /etc/nsswitch.conf file.

What should be returned: (gethostbyname((POSIX::uname)[1]))[0]

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




More information about the Perl-maintainers mailing list