diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-07 06:36:33 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-07 06:36:33 +0000 |
commit | 154a3d541e7a9364fb47632cc34c63cdb1d8eda3 (patch) | |
tree | 681e71c4d45f70b4c36258283ec85accfa916ff2 | |
parent | 3c77ea2bace63b1ad27d15a6366cb938bdd158cb (diff) | |
download | perl-154a3d541e7a9364fb47632cc34c63cdb1d8eda3.tar.gz |
partly revert change#4851, apparently POSIX::uname() may not be correct
per strict reading of standard (says Tom Christiansen)
p4raw-link: @4851 on //depot/perl: 6bb694c13adc449f32ff24c71221152025ccae6c
p4raw-id: //depot/perl@5012
-rw-r--r-- | lib/Sys/Hostname.pm | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Sys/Hostname.pm b/lib/Sys/Hostname.pm index 87d10520df..63415a6bfe 100644 --- a/lib/Sys/Hostname.pm +++ b/lib/Sys/Hostname.pm @@ -71,21 +71,15 @@ sub hostname { } else { # Unix - # method 2 - use POSIX.pm, prefer the standard library to system calls + # method 2 - syscall is preferred since it avoids tainting problems eval { local $SIG{__DIE__}; - require POSIX; - $host = (POSIX::uname())[1]; - } - # method 3 - otherwise syscall is preferred since it avoids tainting problems - || eval { - local $SIG{__DIE__}; require "syscall.ph"; $host = "\0" x 65; ## preload scalar syscall(&SYS_gethostname, $host, 65) == 0; } - # method 3a - syscall using systeminfo instead of gethostname + # method 2a - syscall using systeminfo instead of gethostname # -- needed on systems like Solaris || eval { local $SIG{__DIE__}; @@ -95,13 +89,21 @@ sub hostname { syscall(&SYS_systeminfo, &SI_HOSTNAME, $host, 65) != -1; } - # method 4 - trusty old hostname command + # method 3 - trusty old hostname command || eval { local $SIG{__DIE__}; local $SIG{CHLD}; $host = `(hostname) 2>/dev/null`; # bsdish } + # method 4 - use POSIX::uname(), which strictly can't be expected to be + # correct + || eval { + local $SIG{__DIE__}; + require POSIX; + $host = (POSIX::uname())[1]; + } + # method 5 - sysV uname command (may truncate) || eval { local $SIG{__DIE__}; |