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
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__};