G'day Bod,
I didn't see it mentioned anywhere in the thread,
so I thought I'd point out a general problem that you could be experiencing.
Here's a taint_test module:
$ cat taint_test.pm
package taint_test;
use strict;
use warnings;
chdir +(split /:/, $ENV{PATH})[0];
Here's a script that tries to clean $ENV{PATH}:
$ cat check_taint_1.pl
use strict;
use warnings;
$ENV{PATH} = '/bin:/usr/bin';
use lib '.';
use taint_test;
But that fails:
$ perl -T check_taint_1.pl
Insecure dependency in chdir while running with -T switch at taint_tes
+t.pm line 6.
Compilation failed in require at check_taint_1.pl line 6.
BEGIN failed--compilation aborted at check_taint_1.pl line 6.
$
The problem here is that the assignment to $ENV{PATH} occurs at runtime,
whereas loading taint_test occurs at compile time.
The order of the statements makes no difference: compile time happens before runtime.
Here's a subtly different version of the first script:
$ cat check_taint_2.pl
use strict;
use warnings;
BEGIN { $ENV{PATH} = '/bin:/usr/bin'; }
use lib '.';
use taint_test;
And this one works:
$ perl -T check_taint_2.pl
$
Both assignment and loading occur at compile time; the order of the statements now matters.
Here's a third version of the script with the order of statements changed:
$ cat check_taint_3.pl
use strict;
use warnings;
use lib '.';
use taint_test;
BEGIN { $ENV{PATH} = '/bin:/usr/bin'; }
And, as expected, this fails:
$ perl -T check_taint_3.pl
Insecure dependency in chdir while running with -T switch at taint_tes
+t.pm line 6.
Compilation failed in require at check_taint_3.pl line 5.
BEGIN failed--compilation aborted at check_taint_3.pl line 5.
$
Bear this in mind for things other than untainting $ENV{PATH}.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.