B
bwooster47
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 $?/" . ($? >> 8) . " : $!
\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
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 $?/" . ($? >> 8) . " : $!
\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