in some older AIX versions, the Socket6.pm is not available, but will have IPv6 address ::1 configured on loopback, need to avoid passing ipv6 address to inet_* calls

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6103 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
ligc 2010-05-14 01:36:40 +00:00
parent 6e7232725a
commit d33c3d4443

View File

@ -140,6 +140,12 @@ sub gethostname()
}
else
{
#it is possible that no Socket6 available,
#but passing in IPv6 address, such as ::1 on loopback
if ($iporhost =~ /:/)
{
return undef;
}
my $hostname = gethostbyaddr(inet_aton($iporhost), AF_INET);
$hostname =~ s/\..*//; #short hostname
return $hostname;
@ -207,6 +213,7 @@ sub getipaddr()
else
{
#return inet_ntoa(inet_aton($iporhost))
#TODO, what if no scoket6 support, but passing in a IPv6 hostname?
my $packed_ip = inet_aton($iporhost);
if (!$packed_ip)
{