Race condition check triggered by automounter.
File::Path's _rmtree function contains a race condition check that
clashes with OpenSolaris NFS mirror mounts, and possibly NFS automounts,
aswell. The check is necessary and good, but needs a small additional
step when dynamic mounts are used.
The current steps are:
1. lstat($root)
2. chdir($root)
3. stat(".")
and then compare inode and FS ids.
NFS mirror mounts are not triggered by an lstat() on the mount point, so
the inode and FS id of the mount point are returned. chmod() however
triggers the mounting of the share, and the second stat() returns
different ids - the inode of the share's root directory.
I've added a simple "step 0" to work around this, which will trigger the
auto-mount before the unaltered race condition check is performed. This
should have only minimal performance and no security impact, but it also
works with mirror mounts.
With added step:
0. stat(File::Spec->catdir($root, $curdir)) # e.g. "$root/." on *nix
1. lstat($root)
2. chdir($root)
3. stat(".")
Step 0 triggers the automount, so the inodes will now match.
I've added a (very simple) patch file for your convenience.
Subject: | file_path_mirrormount.patch |
diff -crB File-Path-2.08/Path.pm File-Path-2.08.patched/Path.pm
*** File-Path-2.08/Path.pm Sun Oct 4 12:15:58 2009
--- File-Path-2.08.patched/Path.pm Mon Feb 20 16:29:21 2012
***************
*** 276,281 ****
--- 276,285 ----
: $root
;
+ # trigger possible automount / mirror mount before race condition stat
+ my $root_plus_curdir = File::Spec->catfile($root, $curdir);
+ stat $root_plus_curdir; # ignore result
+
my ($ldev, $lino, $perm) = (lstat $root)[0,1,2] or next ROOT_DIR;
if ( -d _ ) {