Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > mod_perl ignoring changed to $ENV{{PATH}?

Reply
Thread Tools

mod_perl ignoring changed to $ENV{{PATH}?

 
 
bwooster47
Guest
Posts: n/a
 
      01-15-2008
I've narrowed down to a simple script a problem where it looks like
when running under mod_perl, it does not support changes to the
$ENV{PATH} variable - it does require the assignment to avoid the
tainting, but then any assignment itself does not take effect - I
added /usr/local/bin to PATH, but am unable to execute commands in
that folder when running under mod_perl.

Could not find anything about this in the mod_perl web pages, but a
Usenet search seems to suggest that mod_perl only honors PerlSetEnv
PATH in config, and does not honor PATH changes in the script? That
does not sound right, what about the cases where a PATH change is
needed for some scripts only, so a global PerlSetEnv would be too
much.

Example - for testing, I copied /bin/echo to /usr/local/bin/echo, and
then ran this script - it runs fine when run under the shell, but when
run under Apache + mod_perl, it fails.

Script:
#!/usr/bin/perl -Tw

print "Content-type: text/plain\n\n";

$ENV{PATH} = "/bin:/usr/bin:/usr/local/bin:";
foreach ( "echo", "myecho", "/usr/local/bin/myecho") {
print "------ Testing command '$_'\n";
my $string = `$_ testing execution of '$_'`;
print " failed to execute '$_', \$? is $?/" . ($? >> . " : $!
\n"
if ($? != 0);
print " \$string is: $string\n";
}

Shell output (perl -Tw script)
Content-type: text/plain

------ Testing command 'echo'
$string is: testing execution of echo

------ Testing command 'myecho'
$string is: testing execution of myecho

------ Testing command '/usr/local/bin/myecho'
$string is: testing execution of /usr/local/bin/myecho

Web page output - this fails to execute myecho without the path:
------ Testing command 'echo'
$string is: testing execution of echo

------ Testing command 'myecho'
failed to execute 'myecho', $? is 32512/127 :
$string is:
------ Testing command '/usr/local/bin/myecho'
$string is: testing execution of /usr/local/bin/myecho

 
Reply With Quote
 
 
 
 
ian.sillitoe@googlemail.com
Guest
Posts: n/a
 
      01-29-2008
On Jan 15, 3:30 pm, bwooster47 <(E-Mail Removed)> wrote:
> I've narrowed down to a simple script a problem where it looks like
> when running undermod_perl, it does not support changes to the
> $ENV{PATH} variable - it does require the assignment to avoid the
> tainting, but then any assignment itself does not take effect - I
> added /usr/local/bin to PATH, but am unable to execute commands in
> that folder when running undermod_perl.
>
> Could not find anything about this in themod_perlweb pages, but a
> Usenet search seems to suggest thatmod_perlonly honors PerlSetEnv
> PATH in config, and does not honor PATH changes in the script? That
> does not sound right, what about the cases where a PATH change is
> needed for some scripts only, so a global PerlSetEnv would be too
> much.
>
> Example - for testing, I copied /bin/echo to /usr/local/bin/echo, and
> then ran this script - it runs fine when run under the shell, but when
> run under Apache +mod_perl, it fails.
>
> Script:
> #!/usr/bin/perl -Tw
>
> print "Content-type: text/plain\n\n";
>
> $ENV{PATH} = "/bin:/usr/bin:/usr/local/bin:";
> foreach ( "echo", "myecho", "/usr/local/bin/myecho") {
> print "------ Testing command '$_'\n";
> my $string = `$_ testing execution of '$_'`;
> print " failed to execute '$_', \$? is $?/" . ($? >> . " : $!
> \n"
> if ($? != 0);
> print " \$string is: $string\n";
>
> }
>
> Shell output (perl -Tw script)
> Content-type: text/plain
>
> ------ Testing command 'echo'
> $string is: testing execution of echo
>
> ------ Testing command 'myecho'
> $string is: testing execution of myecho
>
> ------ Testing command '/usr/local/bin/myecho'
> $string is: testing execution of /usr/local/bin/myecho
>
> Web page output - this fails to execute myecho without the path:
> ------ Testing command 'echo'
> $string is: testing execution of echo
>
> ------ Testing command 'myecho'
> failed to execute 'myecho', $? is 32512/127 :
> $string is:
> ------ Testing command '/usr/local/bin/myecho'
> $string is: testing execution of /usr/local/bin/myecho


This looks like a 'Taint' issue - I would check by running it without
the 'T' switch. If you want to use Taint (which you will) then you
could look at the perl5lib CPAN package which is Taint-safe

http://search.cpan.org/~nobull/perl5...ib/perl5lib.pm
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla & Firefox ignoring my Hosts file Captain Infinity Firefox 4 09-03-2009 10:55 AM
changed state to up changed state to down FastEthernet LINEPROTO-5-UPDOWN surrealarmada@gmail.com Cisco 3 03-07-2007 06:06 PM
scroll position is changed when style is changed? mxbrunet Javascript 1 11-03-2006 03:40 AM
mod_perl installed, but mod_perl.so file not created bennett@peacefire.org Perl Misc 2 01-25-2006 10:53 PM
xmlDocument.Save "&#10;" getting changed changed to "&amp;#10" st@jpa.co.jp ASP .Net 1 10-11-2005 01:30 PM



Advertisments