September 11 2017 | File::Path Security | Back Next |
You'll have to restore reasonable permissions to $second_level_dir before calling rmtree() on its parent
$cwd = cwd(); $first_level_subdir = "$cwd/alpha"; mkdir $first_level_subdir, 0755;
$second_level_subdir = "$first_level_subdir/beta"; mkdir $second_level_subdir, 0200;
# do something that needs a directory with 0200 permissions
chmod 0755, $second_level_subdir; # <-- Add one chmod call
rmtree('alpha'); (! -d $second_level_subdir) and say "$second_level_subdir removed"; (! -d $first_level_subdir) and say "$first_level_subdir removed";
Home Last TOC | Copyright © 2017 James E Keenan | Back Next |