PapaJohn454 has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Perl Guardians
Encountering a problem I've never seen before while running -T
Insecure $ENV{ENV} while running with -T switch at /u/beta/coampsos/COSL/COAMPSOS/lib/COAMPSOS_rmon_monitor_tools.pm line 1496.
NOTE it says $ENV{ENV} and not $ENV{PATH} line 1496 is: open(CMD,"$cmd 2>&1 |") || return ($!);
From the following routine:
# Runs a command under -T captures output ###################################################################### +######## sub run_cmd_safely{ my ($cmd) = @_; my ($DEBUG) = 0; #$DEBUG = 1 if ($cmd =~ /nexsat/i); if ($DEBUG == 1){ use CGI; my $query = new CGI; print $query->header; } print "<p>Initially command = $cmd\n" if ($DEBUG == 1); # Need to untaint and run in a restricted environment { $cmd =~ /([\~\*\w\_\-\%\+\/\.\,\!\s\"\'\|\\\>\<\&]+)/; $cmd = $1; } print "<p>After untaint cmd = $cmd\n" if ($DEBUG == 1); my ($ORIG_PATH) = $ENV{'PATH'}; $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin"; my (@RESULTS); # Remove any trailing | $cmd =~ s/\|\s*$//; print "<p>Really Running $cmd\n<p>" if ($DEBUG == 1); open(CMD,"$cmd 2>&1 |") || return ($!); print "Successfully opened $cmd\n" if ($DEBUG == 1); while(<CMD>){ chomp($_); next if ($_ =~ /sh /); next if ($_ =~ /grep /); print "<br>Pushing $_\n" if ($DEBUG == 1); push (@RESULTS,$_) if ($_ =~ /\w+/); } close (CMD); $ENV{'PATH'} = $ORIG_PATH; return (\@RESULTS); } ############################################################
This routine runs fine on "most" machines. It's just not running on a customer's.
Thank you for your help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Insecure Environment ?
by Anonymous Monk on Jul 22, 2014 at 22:07 UTC | |
|
Re: Insecure Environment ?
by kennethk (Abbot) on Jul 22, 2014 at 23:36 UTC | |
by dave_the_m (Monsignor) on Jul 23, 2014 at 07:55 UTC |