From 67693aa57fec51f6f6d1a25162537acf9a943624 Mon Sep 17 00:00:00 2001 From: Tim Bunce Date: Fri, 5 Sep 1997 00:00:00 +0000 Subject: [PATCH] Sys::Hostname fails under Solaris 2.5 when setuid (this is the same change as commit b6d5cd8ca8d16f83d5c4c7a0bc602634e3efb321, but as applied) --- lib/Sys/Hostname.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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__}; -- 2.7.4