Fix call to open_lock_tempfile on a symlink
authorJamie Cameron <jcameron@webmin.com>
Wed, 19 Oct 2011 04:52:45 +0000 (21:52 -0700)
committerJamie Cameron <jcameron@webmin.com>
Wed, 19 Oct 2011 04:52:45 +0000 (21:52 -0700)
web-lib-funcs.pl

index aca631e..16a2a52 100755 (executable)
@@ -8428,6 +8428,11 @@ $fh = &callers_package($fh);
 my $lockfile = $file;
 $lockfile =~ s/^[^\/]*//;
 if ($lockfile =~ /^\//) {
+       while(-l $lockfile) {
+               # If the file is a link, follow it so that locking is done on
+               # the same file that gets unlocked later
+               $lockfile = &resolve_links($lockfile);
+               }
        $main::open_templocks{$lockfile} = &lock_file($lockfile);
        }
 return &open_tempfile($fh, $file, $noerror, $notemp, $safe);