From: Tim Bunce Date: Fri, 5 Sep 1997 00:00:00 +0000 (+0000) Subject: Sys::Hostname fails under Solaris 2.5 when setuid X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=67693aa57fec51f6f6d1a25162537acf9a943624;p=p5sagit%2Fp5-mst-13.2.git Sys::Hostname fails under Solaris 2.5 when setuid (this is the same change as commit b6d5cd8ca8d16f83d5c4c7a0bc602634e3efb321, but as applied) --- diff --git a/lib/Sys/Hostname.pm b/lib/Sys/Hostname.pm index d23310a..95f9a99 100644 --- a/lib/Sys/Hostname.pm +++ b/lib/Sys/Hostname.pm @@ -78,6 +78,19 @@ sub hostname { syscall(&main::SYS_gethostname, $host, 65) == 0; } + # method 2a - syscall using systeminfo instead of gethostname + # -- needed on systems like Solaris + || eval { + local $SIG{__DIE__}; + { + package main; + require "sys/syscall.ph"; + require "sys/systeminfo.ph"; + } + $host = "\0" x 65; ## preload scalar + syscall(&main::SYS_systeminfo, &main::SI_HOSTNAME, $host, 65) != -1; + } + # method 3 - trusty old hostname command || eval { local $SIG{__DIE__};