leocharre has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: having horrors untainting a path string for moving a file
by virtualsue (Vicar) on Mar 14, 2006 at 18:39 UTC | |
|
Re: having horrors untainting a path string for moving a file
by ikegami (Patriarch) on Mar 14, 2006 at 18:37 UTC | |
by Fletch (Bishop) on Mar 14, 2006 at 18:47 UTC | |
by ikegami (Patriarch) on Mar 14, 2006 at 18:50 UTC |