B
Ben
I have a .PL script that is attempting to invoke an external command
once launched from a web page. The command takes quite a while to run
(could be hours), so it is important that it detach so the user can
come back later. The command generates result webpages elsewhere. This
command also takes some parameters. The environment is 100% secure,
non-internet connected intranet, there are NO security issues, so
please refrain from telling me how wonderful taint is and that I
should be using it, because in this case, it... taint so darned
wonderful, it's just a pain in the tush. I understand why I might
want taint under other circumstances, even most other circumstances...
It just doesn't apply here at all.
I'll explain everything I can think of:
Under perl 5 and redhat 6.0, this was no problem. Under perl 5.8.0 and
redhat 9, perl would not invoke the command, in a manner that leads me
to think it was a result of taint being on.
This creates the command string I want:
$cmd = "/usr/src/client/client $p1 $p1 $p3 $p4 &";
Then:
system($cmd);
....would invoke it under RH6 and P5.0, and all was well.
Now, under RH9 and P5.8 (or the apache perl module, which I suspect is
actually handling this), perl is acting like taint is on (I didn't
turn it on, and I can't find where it's turned on, more on that in a
bit.) So, as instructed in the perl faq, I attempt to un-taint the
variable:
$cmd =~ /(.*)/;
....then either:
$cmd = $1;
system($cmd);
....or
system($1);
....but neither one works - the command is not invoked. Still acts like
it is tainted.
This works (as indicated by the faq, because the command isn't coming
from a variable), but does not detach (is there a way to MAKE it
detach?):
system("/usr/src/client/client",$p1,$p2,$p3,$p4);
....because it does not detach, the perl script still hangs the web
page, the web page eventually times out, which also (sigh) stops the
command 'client' from executing for some reason.
This also times out and kills the web page AND the running command
'client':
exec("/usr/src/client/client",$p1,$p2,$p3,$p4);
exit;
Now, about taint apparently being on. The shebang line in my script is
vanilla, just says #!/usr/bin/perl
The /etc/httpd/conf.d/perl.conf file does NOT contain a command to
turn on taint, just commented out areas and the single lonely command:
LoadModule perl_module modules/perl.so
the /etc/httpd/conf/httpd.conf file contains no reference to perl at
all, other than a remark about pl being a language extension.
I am running in a non-secure server, and so httpd.conf is the place
where I would expect to find such a command (assuming it wasn't in
conf.d/perl.conf, of course.)
So I have these questions:
1) Is there a way I can un-taint the $cmd variable so I can run it
just this way:
$cmd = "/usr/src/client/client $p1 $p1 $p3 $p4 &";
#un-tainting magic supposedly like: $cmd =~ /(.*)/; $cmd = $1
system($cmd);
2) Why is taint on in the first place, since there is no -T flag, and
no command I can find to the webserver and hence to the embedded perl
interpreter?
As I mentioned at the start of this missive, this used to work fine on
an older system. The reason we're trying to move it to the newer
system is the newer system is one heck of a lot faster, and this is a
really compute-intensive process. I'm highly motivated, but equally
confused at this point.
I would really, really appreciate some insight into this. Thanks in
advance.
Ben
once launched from a web page. The command takes quite a while to run
(could be hours), so it is important that it detach so the user can
come back later. The command generates result webpages elsewhere. This
command also takes some parameters. The environment is 100% secure,
non-internet connected intranet, there are NO security issues, so
please refrain from telling me how wonderful taint is and that I
should be using it, because in this case, it... taint so darned
wonderful, it's just a pain in the tush. I understand why I might
want taint under other circumstances, even most other circumstances...
It just doesn't apply here at all.
I'll explain everything I can think of:
Under perl 5 and redhat 6.0, this was no problem. Under perl 5.8.0 and
redhat 9, perl would not invoke the command, in a manner that leads me
to think it was a result of taint being on.
This creates the command string I want:
$cmd = "/usr/src/client/client $p1 $p1 $p3 $p4 &";
Then:
system($cmd);
....would invoke it under RH6 and P5.0, and all was well.
Now, under RH9 and P5.8 (or the apache perl module, which I suspect is
actually handling this), perl is acting like taint is on (I didn't
turn it on, and I can't find where it's turned on, more on that in a
bit.) So, as instructed in the perl faq, I attempt to un-taint the
variable:
$cmd =~ /(.*)/;
....then either:
$cmd = $1;
system($cmd);
....or
system($1);
....but neither one works - the command is not invoked. Still acts like
it is tainted.
This works (as indicated by the faq, because the command isn't coming
from a variable), but does not detach (is there a way to MAKE it
detach?):
system("/usr/src/client/client",$p1,$p2,$p3,$p4);
....because it does not detach, the perl script still hangs the web
page, the web page eventually times out, which also (sigh) stops the
command 'client' from executing for some reason.
This also times out and kills the web page AND the running command
'client':
exec("/usr/src/client/client",$p1,$p2,$p3,$p4);
exit;
Now, about taint apparently being on. The shebang line in my script is
vanilla, just says #!/usr/bin/perl
The /etc/httpd/conf.d/perl.conf file does NOT contain a command to
turn on taint, just commented out areas and the single lonely command:
LoadModule perl_module modules/perl.so
the /etc/httpd/conf/httpd.conf file contains no reference to perl at
all, other than a remark about pl being a language extension.
I am running in a non-secure server, and so httpd.conf is the place
where I would expect to find such a command (assuming it wasn't in
conf.d/perl.conf, of course.)
So I have these questions:
1) Is there a way I can un-taint the $cmd variable so I can run it
just this way:
$cmd = "/usr/src/client/client $p1 $p1 $p3 $p4 &";
#un-tainting magic supposedly like: $cmd =~ /(.*)/; $cmd = $1
system($cmd);
2) Why is taint on in the first place, since there is no -T flag, and
no command I can find to the webserver and hence to the embedded perl
interpreter?
As I mentioned at the start of this missive, this used to work fine on
an older system. The reason we're trying to move it to the newer
system is the newer system is one heck of a lot faster, and this is a
really compute-intensive process. I'm highly motivated, but equally
confused at this point.
I would really, really appreciate some insight into this. Thanks in
advance.
Ben