I need to let users via a web interface, to tell the server to move a file from one place to another (i don't like this either).

This file is on a chunk of filetree that is mounted... So, it seems I need to use backticks and mv command. stuff like File::Copy will not steadily work accross filesystems

I'm running -Tw, and it's getting really angry at me for this.. I'm having a hard time untainting paths like /this/that/that/etc

I get this: Insecure $ENV{PATH} while running with -T switch at move.cgi line 148

This is my untainting and moving..

my %a=(); #their files may have @ signs, yea.. sigh # from if ("$$DMS{CONF}{DOC}/$filepath"=~m/^([\/_\@\w .-]+)$/){ $a{from} = $1; } #to if ("$$DMS{CONF}{DOC}/$$DMS{S}{session_file}/$$DMS{F}{$filepath}{file_ +name}"=~m/^([\/_\@\w .-]+)$/){ $a{to}=$1; } $a{from}=~m/\w/ or die("from failed untaint"); $a{to}=~m/\w/ or die("to failed untaint"); my $err = `mv "$a{from}" "$a{to}"`; # and here we freak out if ($err){ die("mov problem.. [$err]"); }

Is there some other way I should be untainting a path?


In reply to having horrors untainting a path string for moving a file by leocharre

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.