Hi,
The sub _hostdomain in Net::Domain.pm is broken.
As the comment suggests, it "assumes" that the first search argument is
the valid domain. Unfortunately, that's not always the case.
Let's say we have two differents vlans (main-servers.example.com and
failback-servers.example.com). In this case, we might have a resolv.conf
like this one :
------------------------------8<------------------------------
search main-servers.example.com failback-servers.example.com
nameserver 192.0.43.10
------------------------------>8------------------------------
_hostdomain will assume that the first one (main-servers.example.com) is
always the good one. But it's not.
In our case, it resulted in a script used to deploy an application to
fail. So we have to modify resolv.conf, relaunch the script and then
modify it again. That's a lot of trouble to spare just a call to a function.
I'm not sure it's still relevant to avoid a call to gethostbyname at the
cost of not being sure that the result would be accurate.
At least bypassing the gethostbyname call should be optional, for people
focusing on performance rather on reliability.
On a side note, there is a bug opened on the Oracle bug tracker since
2006. Unfortunately, these people are dumb enough to keep it closed. But
in the case a reader would have access to it, here is the link:
https://support.oracle.com/CSP/main/article?cmd=show&type=BUG&id=5609719&productFamily=Oracle
Thanks.
libnet: 1.22
Domain.pm $VERSION: 2.21
Perl: 5.8.4
OS: Solaris 10 X86
Have a nice day.