From pckizer@chariot.tamu.edu Thu Sep  2 16:45:40 1999
Return-Path: <pckizer@chariot.tamu.edu>
Received: from chariot.tamu.edu (chariot.tamu.edu [128.194.103.101])
	by hub.freebsd.org (Postfix) with ESMTP id 66B4614CC4
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  2 Sep 1999 16:45:39 -0700 (PDT)
	(envelope-from pckizer@chariot.tamu.edu)
Received: (from root@localhost)
	by chariot.tamu.edu (8.9.3/8.9.3) id SAA02270;
	Thu, 2 Sep 1999 18:41:56 -0500 (CDT)
Message-Id: <199909022341.SAA02270@chariot.tamu.edu>
Date: Thu, 2 Sep 1999 18:41:56 -0500 (CDT)
From: pckizer@tamu.edu
Sender: pckizer@chariot.tamu.edu
Reply-To: pckizer@tamu.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: perl as distributed with 3.2-stable module Sys::Hostname garenteed to fail if no PATH defined prior to calling
X-Send-Pr-Version: 3.2

>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:    markm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep  2 16:50:01 PDT 1999
>Closed-Date:    Mon Mar 28 13:06:46 GMT 2005
>Last-Modified:  Mon Mar 28 13:06:46 GMT 2005
>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:
Responsible-Changed-From-To: freebsd-bugs->sheldonh 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Thu Sep 2 23:19:20 PDT 1999 
Responsible-Changed-Why:  
Sorry, I asked Mark for permission to MFC and then forgot to. I'll 
do it now. 

From: Nick Hibma <nick.hibma@jrc.it>
To: pckizer@tamu.edu
Cc: FreeBSD-gnats-submit@FreeBSD.ORG,
	Sheldon Hearn <sheldonh@uunet.co.za>
Subject: Re: bin/13550: perl as distributed with 3.2-stable module Sys::Hostname
 garenteed to fail if no PATH defined prior to calling
Date: Fri, 3 Sep 1999 09:29:48 +0200 (MET DST)

 What you should be doing in your program is the following:
 
 env PATH= /usr/bin/perl -e '
 $ENV{PATH} = "/bin:/usr/bin"
 	unless $ENV{PATH};
 
 use Sys::Hostname;
 print Sys::Hostname::hostname(),"\n";
 '
 
 The cause of the problem is that the PATH is not set and setting it deep
 down in some library is not the intended use of setting environment
 variables. sendmail removes PATH from the environment for a reason
 (security)
 
 You agree that we close the PR?
 
 
 Nick
 
 
  > --- /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
  > 
  > 
 
 -- 
 ISIS/STA, T.P.270, Joint Research Centre, 21020 Ispra, Italy
 
 
 
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Nick Hibma <nick.hibma@jrc.it>
Cc: pckizer@tamu.edu, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13550: perl as distributed with 3.2-stable module Sys::Hostname garenteed to fail if no PATH defined prior to calling 
Date: Fri, 03 Sep 1999 09:33:01 +0200

 On Fri, 03 Sep 1999 09:29:48 +0200, Nick Hibma wrote:
 
 > You agree that we close the PR?
 
 No. This is a real problem. See rev 1.2 of Hostname.pm .
 
 I'm just waiting for permission from Jordan to MFC Mark's change.
 
 Ciao,
 Sheldon.
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Dec 20 08:56:15 PST 1999 
State-Changed-Why:  
Aaaiieee! This was MFC'd ages ago in rev 1.1.1.1.2.1 of Hostname.pm, 
which made it into 3.3-RELEASE. 

From: Philip Kizer <pckizer@tamu.edu>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc:  
Subject: Re: bin/13550: perl as distributed with 3.2-stable module Sys::Hostname garenteed to fail if no PATH defined prior to calling 
Date: Sun, 09 Apr 2000 11:40:58 -0500

 Sheldon Hearn <sheldonh@uunet.co.za> wrote:
 >No. This is a real problem. See rev 1.2 of Hostname.pm .
 >I'm just waiting for permission from Jordan to MFC Mark's change.
 
 OK, I just took a system to the latest 3.4-STABLE before I start my 4.0
 changes this month, and found that this has not been put in, but the PR has
 been closed.
 
 References:
   PR: <http://www.FreeBSD.org/cgi/query-pr.cgi?pr=bin%2F13550>
 
 Versions with the problem:
   <http://www.FreeBSD.org/cgi/cvsweb.cgi/src/contrib/perl5/lib/Sys/Hostname.pm?rev=1.1.1.1.2.1>
   <http://www.FreeBSD.org/cgi/cvsweb.cgi/src/contrib/perl5/lib/Sys/Hostname.pm?rev=1.2>
 
   % export CVSROOT=:pserver:anoncvs@anoncvs.FreeBSD.org:/home/ncvs
   % cvs login
   % cvs co -rRELENG_4 src/contrib/perl5/lib/Sys/
   cvs server: Updating src/contrib/perl5/lib/Sys
   U src/contrib/perl5/lib/Sys/Hostname.pm
   U src/contrib/perl5/lib/Sys/Syslog.pm
   % ls -l src/contrib/perl5/lib/Sys/Hostname.pm
   -rw-------  1 pckizer  staff  3126 Jul 19  1999 Hostname.pm
 
 Versions as provided by 'standard' perl5 as available from CTAN that do not
 have the problem:
   <http://www.FreeBSD.org/cgi/cvsweb.cgi/src/contrib/perl5/lib/Sys/Hostname.pm?rev=1.1>
   <http://www.FreeBSD.org/cgi/cvsweb.cgi/src/contrib/perl5/lib/Sys/Hostname.pm?rev=1.1.1.1>
 
 The patch is stil just as trivial:
 
 --- Hostname.pm.orig	Fri Apr  7 16:12:04 2000
 +++ Hostname.pm	Fri Apr  7 19:22:51 2000
 @@ -100,2 +100,3 @@
  	$ENV{'PATH'} = $pathstack;
 +	$host;
      }
 @@ -109,2 +110,3 @@
  	$ENV{'PATH'} = $pathstack;
 +	$host;
      }
 
 Looking closer at it there's another problem with it (not that it would be
 shown under FreeBSD given that /bin/hostname _will_ be there).  If the same
 patch were put on some system where 'hostname' failed and a PATH is
 pre-defined, it would always take mathod 3 as having succeeded and never
 get to method 4.
 
 Am I missing something as to why my cvsup's don't have an updated version,
 or was this never actually committed?
 
 
 Thanks,
 
 -philip
 
 -- 
 Philip Kizer <pckizer@tamu.edu>, 409.862.4120
 Texas A&M CIS Operating Systems Group, Unix
 
 
State-Changed-From-To: closed->open 
State-Changed-By: sheldonh 
State-Changed-When: Thu Apr 13 03:34:44 PDT 2000 
State-Changed-Why:  
New evidence... :-) 


Responsible-Changed-From-To: sheldonh->markm 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Thu Apr 13 03:34:44 PDT 2000 
Responsible-Changed-Why:  
Mark, can you check this out? 
State-Changed-From-To: open->closed 
State-Changed-By: markm 
State-Changed-When: Mon Mar 28 13:05:56 GMT 2005 
State-Changed-Why:  
As Perl is no longer part of the base, and as I can't reproduce this 
with the port, close. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13550 
>Unformatted:
