From: Patrick Hayes Date: Wed, 20 Aug 1997 01:05:13 +0000 (+1200) 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=b6d5cd8ca8d16f83d5c4c7a0bc602634e3efb321;p=p5sagit%2Fp5-mst-13.2.git Sys::Hostname fails under Solaris 2.5 when setuid encountered a problem when using the Sys::Hostname under Solaris 2.5.1 in setuid scripts. The problem is due to Solaris' having removed gethostname from the list of syscalls. gethostname is now a libc compatability function using the 'sysinfo' syscall. As the environment I'm using this in requires setuid execution, the other methods (calling `hostname or `uname -n`) are inapplicable. I also noticed that Sys::Hostname requires syscall.ph whereas I find only sys/syscall.ph. The perl headers were created with the standard: cd /usr/include; h2ph * sys/* I've added in the following code to make Hostname.pm work on Solaris. Would it be possible to integrate this into future releases? p5p-msgid: 199708201240.OAA04243@goblin.renault.fr --- diff --git a/lib/Sys/Hostname.pm b/lib/Sys/Hostname.pm index d23310a..7fe3d8f 100644 --- a/lib/Sys/Hostname.pm +++ b/lib/Sys/Hostname.pm @@ -78,6 +78,18 @@ sub hostname { syscall(&main::SYS_gethostname, $host, 65) == 0; } + # method 2a - syscall using systeminfo instead of gethostname + # -- needed on systems like Solaris + || eval { + { + 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__};