I don't think that's it, or at least, that's not the way it works on one Linux/Apache configuration. For one thing, $ENV{ PWD } is not even in the environment of CGI scripts (when run under Apache) in this configuration; here are the keys of %ENV, printed from within one such script:

AUTH_TYPE HTTP_KEEP_ALIVE SCRIPT_FILENAME DOCUMENT_ROOT HTTP_USER_AGENT SCRIPT_NAME GATEWAY_INTERFACE PATH SERVER_ADDR HTTP_ACCEPT PERL5LIB SERVER_ADMIN HTTP_ACCEPT_CHARSET QUERY_STRING SERVER_NAME HTTP_ACCEPT_ENCODING REMOTE_ADDR SERVER_PORT HTTP_ACCEPT_LANGUAGE REMOTE_PORT SERVER_PROTOCOL HTTP_CONNECTION REMOTE_USER SERVER_SIGNATURE HTTP_COOKIE REQUEST_METHOD SERVER_SOFTWARE HTTP_HOST REQUEST_URI
Furthermore, if I run the CGI script listed below on my server, untainting the input filename (by passing a non-zero untaint param to the script) is sufficient to appease -T, even though I am creating and unlinking a file in a relative directory (../TRASH); if the filename is not untainted, however, -T kills the script at the unlinking step.

#!/usr/bin/perl -T use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser carpout); my $q = CGI->new(); my $untaint = $q->param('untaint'); my $f = $q->param('filename'); print $q->header, $q->start_html; if ( $f ) { $f = ( $f =~ m/([\w-]+)/ )[ 0 ] if $untaint; if ( $f ) { print "Creating $f<br>\n"; { my $out; open $out, '>', "../TRASH/$f" and close $out or die "Failed to create $f: $!"; } print "Unlinking $f<br>\n"; unlink "../TRASH/$f"; print $q->h3( 'ok' ); } else { print $q->h3( 'Bad filename: ' . $q->param( 'filename' ) ); } } else { print $q->h3( 'Missing filename' ); } print $q->end_html;

the lowliest monk


In reply to Re^2: Unlink under taint mode by tlm
in thread Unlink under taint mode by Andre_br

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.