mt2k has asked for the wisdom of the Perl Monks concerning the following question:
In this way, the filename would be passed straight from the user to the perl script (which is why I need to make sure that the user cannot edit files above their user directory. I just want to know that this is 100% safe for the server.
Here is a quick code sample of what I am planning:
#!/usr/bin/perl #Some code to read arguments passed to the script #Read STDIN (GET & POST) into %input hash if ($input{'file'} !~ /^\// && $input{'file'} !~ /\.\./) { open FILE, ">/home/user/www-root/users/files/$username/$input{'file'}" + or die "Error opening file!"; print FILE $input{'file_contents'}; close FILE; } else { #produce some error denying access to this file }
Would this suffice security wise? Thanks a lot ahead of time!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Restricting Web Directory Access
by Zaxo (Archbishop) on Mar 01, 2002 at 06:18 UTC | |
|
Re: Restricting Web Directory Access
by mattr (Curate) on Mar 01, 2002 at 07:31 UTC | |
|
Re: Restricting Web Directory Access
by jlongino (Parson) on Mar 01, 2002 at 06:10 UTC | |
|
Re: Restricting Web Directory Access
by mt2k (Hermit) on Mar 01, 2002 at 15:16 UTC | |
by thraxil (Prior) on Mar 01, 2002 at 22:05 UTC |