[Wellington-pm] chmod, chown and friends.

Jacinta Richardson jarich at perltraining.com.au
Sat Aug 21 20:02:56 CDT 2004


Grant McLean wrote:

> Don't be afraid to do:
> 
>   system("chown -R user:group directory");

system("chown", "-R", "user:group", "directory");

is even better (security wise) if any of the arguments are likely to be 
provided through variables, and particularly if any are likely to have 
come in some way from outside your program.

Do note, that this multi-arg version of system treats all arguments 
literally, so that if you do:

my $directory = <>;
system("chown", "-R", "user:group", $directory);

Then if $directory ends with a newline then it will apply chown to a 
directory name matching $directory including the newline!

All the best,

     Jacinta

-- 
    ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
     `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
     (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
   _..`--'_..-_/  /--'_.' ,'           | contact at perltraining.com.au |
(il),-''  (li),'  ((!.-'              |   www.perltraining.com.au   |




More information about the Wellington-pm mailing list