You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ben Cohen <bc...@uswest.net> on 2000/06/06 04:57:13 UTC

Solution for: Re: $ENV{PATH} set by mod_perl script affects mod_cgi scripts

Thanks to all for the helpful suggestions.

Gunther Birzniek from the list suggested a solution that I've 
now tried and it works perfectly:


{begin quote}

I assume you are running with Apache:Registry?

You could also save off the $ENV{PATH}...


Go to the line that reads:

     eval { &{$cv}($r, @_) } if $r->seqno;


And before it have something like

$ENV{OLD_PATH} = $ENV{PATH}

and after it

$ENV{PATH} = $ENV{OLD_PATH}


{end quote}


This was certainly a weird bug ( I think it was a bug ).
Even setting PerlSetEnv in httpd.conf didn't help.
The PATH would be properly set until the first time a mod_perl
script modified its PATH at which point all other 
scripts including mod_cgi scripts would 'inherit' this
new PATH.


The reason the mod_perl script modifying its path was to appease
the perl taint checking and help ensure a more secure environment.
I could be totally mistaken in doing this and for some strange
reason mod_perl scripts in my install seem to run with taint checking 
on by default.


Thanks again to all those who responded with very 
helpful suggestions,


-Ben




--
   DO NOT LOOK INTO LASER
    WITH REMAINING EYE
(random sig #14)

Re: Solution for: Re: $ENV{PATH} set by mod_perl script affects mod_cgi scripts

Posted by Dirk Lutzebaeck <lu...@aeccom.com>.
Ben Cohen writes:
 > Go to the line that reads:
 > 
 >      eval { &{$cv}($r, @_) } if $r->seqno;

I love perl :)

Dirk


Re: Solution for: Re: $ENV{PATH} set by mod_perl script affects mod_cgi scripts

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 6 Jun 2000, Ben Cohen wrote:
 
> This was certainly a weird bug ( I think it was a bug ).
> Even setting PerlSetEnv in httpd.conf didn't help.
> The PATH would be properly set until the first time a mod_perl
> script modified its PATH at which point all other 
> scripts including mod_cgi scripts would 'inherit' this
> new PATH.

you should be able to cure this simply by localizing:

local $ENV{PATH} = "/bin:/usr/local/bin";

is that not the case?


Re: Solution for: Re: $ENV{PATH} set by mod_perl script affects mod_cgi scripts

Posted by Ken Williams <ke...@forum.swarthmore.edu>.
bcohen2@uswest.net (Ben Cohen) wrote:
>{begin quote}
>
>I assume you are running with Apache:Registry?
>
>You could also save off the $ENV{PATH}...
>
>
>Go to the line that reads:
>
>     eval { &{$cv}($r, @_) } if $r->seqno;
>
>
>And before it have something like
>
>$ENV{OLD_PATH} = $ENV{PATH}
>
>and after it
>
>$ENV{PATH} = $ENV{OLD_PATH}
>
>
>{end quote}


A better solution would be to do "local $ENV{PATH} = $ENV{PATH};".  Let
Perl clean up after you, especially if your script dies in mid-run.

The same technique is used for $^W in RegistryNG.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



Re: Solution for: Re: $ENV{PATH} set by mod_perl script affects mod_cgi scripts

Posted by Matt Sergeant <ma...@sergeant.org>.
On Tue, 6 Jun 2000, Ben Cohen wrote:

> Thanks to all for the helpful suggestions.
> 
> Gunther Birzniek from the list suggested a solution that I've 
> now tried and it works perfectly:
> 
> 
> {begin quote}
> 
> I assume you are running with Apache:Registry?
> 
> You could also save off the $ENV{PATH}...
> 
> 
> Go to the line that reads:
> 
>      eval { &{$cv}($r, @_) } if $r->seqno;

Ugh... Hate that syntax - can we patch it to:

	eval { $cv->($r, @_) } if $r->seqno;

It's so much less cryptic.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org