Date: Thu, 2 Sep 1999 18:41:56 -0500 (CDT) From: pckizer@tamu.edu To: FreeBSD-gnats-submit@freebsd.org Subject: bin/13550: perl as distributed with 3.2-stable module Sys::Hostname garenteed to fail if no PATH defined prior to calling Message-ID: <199909022341.SAA02270@chariot.tamu.edu>
next in thread | raw e-mail | index | archive | help
>Number: 13550 >Category: bin >Synopsis: If no PATH is defined when calling Sys::Hostname::hostname, the function will fail due to exit values of the eval-uated code segments >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 2 16:50:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Philip Kizer >Release: FreeBSD 3.2-STABLE i386 >Organization: Texas A&M University >Environment: FreeBSD chariot.tamu.edu 3.2-STABLE FreeBSD 3.2-STABLE #1: Thu Sep 2 11:17:58 CDT 1999 root@chariot.tamu.edu:/usr/src/sys/compile/Console i386 >Description: I'm sending this as a FreeBSD send-pr since the Sys/Hostname.pm that came with perl5.005_03 as of my latest cvsup this morning differs from the Sys/Hostname.pm as shipped with perl5.005_03 as distributed via CPAN. The Sys/Hostname.pm as cvsup-ed this morning differs from the CPAN distributed perl5.005_03 Sys/Hostname.pm as follows: --- /tmp/perl5.005_03/lib/Sys/Hostname.pm Thu Sep 2 18:13:51 1999 +++ Hostname.pm-orig Thu Sep 2 18:27:32 1999 @@ -95,4 +95,7 @@ || eval { + $pathstack = $ENV{'PATH'}; + $ENV{'PATH'} = "/bin:/usr/bin"; local $SIG{__DIE__}; $host = `(hostname) 2>/dev/null`; # bsdish + $ENV{'PATH'} = $pathstack; } @@ -101,4 +104,7 @@ || eval { + $pathstack = $ENV{'PATH'}; + $ENV{'PATH'} = "/bin:/usr/bin"; local $SIG{__DIE__}; $host = `uname -n 2>/dev/null`; ## sysVish + $ENV{'PATH'} = $pathstack; } The problem this causes is that the eval-ed blocks are guarenteed to be taken as having failed as they will exit with the undef from the $ENV{'PATH'} variable assignment in the case where there is no PATH defined prior to the function call (such as, in my case, an automated invocation from sendmail), >How-To-Repeat: % /usr/bin/perl -e 'use Sys::Hostname; print Sys::Hostname::hostname(),"\n";' chariot.tamu.edu % env PATH= /usr/bin/perl -e 'use Sys::Hostname; print Sys::Hostname::hostname(),"\n";' Cannot get host name of local machine at -e line 1 >Fix: The code blocks need to exit with a return value based on the success of the hostname determination. My quick fix was the following: --- Hostname.pm-orig Thu Sep 2 18:27:32 1999 +++ Hostname.pm Thu Sep 2 18:33:13 1999 @@ -100,2 +100,3 @@ $ENV{'PATH'} = $pathstack; + $host; } @@ -109,2 +110,3 @@ $ENV{'PATH'} = $pathstack; + $host; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199909022341.SAA02270>