Sys::Hostname fails under Solaris 2.5 when setuid
[p5sagit/p5-mst-13.2.git] / lib / Sys / Hostname.pm
index d23310a..7fe3d8f 100644 (file)
@@ -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__};