Item13598: Error renaming a symlinked web using PlainFile Store.
Priority: Urgent
Current State: Closed
Released In: 2.0.2
Target Release: patch
How to repo
- Install fresh foswiki for example into "/var/web/foswiki"
- create some web, e.g. "Hupikek"
- stop foswiki
- move the directory "/var/web/foswiki/data/Hupikek to somewhere for example /var/web/Hupikek
- symlink the previously moved web into the data: ln -s /var/web/Hupikek /var/web/foswiki/data/Hupikek
in short - use symlinked web in some installation.
- use the new wiki (it of course, works ok with the symlinked Hupikek web, you can create topic, attach files - anything.)
- now, go to Hupikek/WebPreferences
- click rename the web for example to "Huhu"
- after the confirmation it dies with the error bellow
the result:
- it creates a new Huhu web
- moves everything from the Hupikek to Huhu
- and dies...
- imho - urgent showstopper (but if want, lower the priority to normal).
During rename of web Hupikek to Huhu an error (PlainFile: move /me/fw/sites/skindev/Foswiki-2.0.0/data/Hupikek to /me/fw/sites/skindev/Foswiki-2.0.0/data/Huhu failed: Not a directory at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/Store/PlainFile.pm line 1420. at /Users/clt/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/CGI/Carp.pm line 357. CGI::Carp::realdie("PlainFile: move /me/fw/sites/skindev/Foswiki-2.0.0/data/Hupi"...) called at /Users/clt/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/CGI/Carp.pm line 449 CGI::Carp::die("PlainFile: move /me/fw/sites/skindev/Foswiki-2.0.0/data/Hupi"...) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/Store/PlainFile.pm line 1420 Foswiki::Store::PlainFile::_moveFile("/me/fw/sites/skindev/Foswiki-2.0.0/data/Hupikek", "/me/fw/sites/skindev/Foswiki-2.0.0/data/Huhu") called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/Store/PlainFile.pm line 317 Foswiki::Store::PlainFile::moveWeb(Foswiki::Store::PlainFile=HASH(0x7f98ad9d0fa8), Foswiki::Meta=HASH(0x7f98ad3eee40), Foswiki::Meta=HASH(0x7f98ad3b9898), "BaseUserMapping_333") called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/Meta.pm line 2319 Foswiki::Meta::move(Foswiki::Meta=HASH(0x7f98ad3eee40), Foswiki::Meta=HASH(0x7f98ad3b9898)) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/UI/Rename.pm line 675 Foswiki::UI::Rename::__ANON__() called at /Users/clt/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/Error.pm line 421 eval {...} called at /Users/clt/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/Error.pm line 413 Error::subs::try(CODE(0x7f98ad52fd08), Foswiki::Meta=HASH(0x7f98ad530098)) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/UI/Rename.pm line 692 Foswiki::UI::Rename::_renameWeb(Foswiki=HASH(0x7f98ad029228), "Hupikek") called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/UI/Rename.pm line 82 Foswiki::UI::Rename::rename(Foswiki=HASH(0x7f98ad029228)) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/UI.pm line 374 Foswiki::UI::__ANON__() called at /Users/clt/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/Error.pm line 421 eval {...} called at /Users/clt/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/Error.pm line 413 Error::subs::try(CODE(0x7f98ab816580), HASH(0x7f98ac69bc30)) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/UI.pm line 500 Foswiki::UI::_execute(Foswiki::Request=HASH(0x7f98abf27530), CODE(0x7f98ac62e380), "rename", 1) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/UI.pm line 326 Foswiki::UI::handleRequest(Foswiki::Request=HASH(0x7f98abf27530)) called at /me/fw/sites/skindev/Foswiki-2.0.0/lib/Foswiki/Engine/CGI.pm line 99 Foswiki::Engine::CGI::run(Foswiki::Engine::CGI=HASH(0x7f98ac37f9f8)) called) was found. Please notify your Foswiki administrator.
What is the ratio behind this code?
1406 # Move a file or directory from one absolute file path to another.
1407 # if the destination already exists it's an error.
1408 sub _moveFile {
1409 my ( $from, $to ) = @_;
1410 die "PlainFile: move target $to already exists" if _e $to;
1411 _mkPathTo($to);
1412 my $ok;
1413 my $efrom = _encode($from);
1414 if ( -d $efrom ) {
1415 $ok = File::Copy::Recursive::dirmove( $efrom, _encode($to) );
1416 }
1417 elsif ( -e $efrom ) {
1418 $ok = File::Copy::move( $efrom, _encode($to) );
1419 }
1420 $ok or die "PlainFile: move $from to $to failed: $!";
1421 }
At the web-rename why doesn't just don't rename the $efrom to $to? Works for directories and symlinks too. Web simple rename isn't cross-filesystem thing (we have only one "data" and one "pub" dir). And when the symlinked web is cross-filesystem, the symlink got renamed and still will point to the right! place.
E.g. the wanted result is:
#Before rename
# ls -l data
lrwxr-xr-x 1 clt wheel 26 1 aug 22:44 Hupikek -> ../../datapub/Some/data
drwxr-xr-x@ 32 clt wheel 1088 4 júl 17:57 Main
drwxr-xr-x 1 clt wheel 1244 1 aug 22:44 Partner
drwxr-xr-x@ 19 clt wheel 646 4 júl 17:57 Sandbox
drwxr-xr-x@ 474 clt wheel 16116 4 júl 17:57 System
#after the "correct" rename webs: 1.) Hupikek to Huhu 2.) and the Partner to Ppp
# ls -l data
lrwxr-xr-x 1 clt wheel 26 1 aug 22:44 Huhu -> ../../datapub/Some/data
drwxr-xr-x@ 32 clt wheel 1088 4 júl 17:57 Main
drwxr-xr-x 1 clt wheel 1244 1 aug 22:44 Ppp
drwxr-xr-x@ 19 clt wheel 646 4 júl 17:57 Sandbox
drwxr-xr-x@ 474 clt wheel 16116 4 júl 17:57 System
--
JozefMojzis - 01 Aug 2015
Confirmed. I've encountered two issues when recreating this issue:
- Running with -T enabled (via Foswiki::Assert and Taint::Runtime)
| 2015-08-14T22:21:20-04:00 error | Insecure dependency in symlink while running with -T switch at /usr/share/perl5/File/Copy/Recursive.pm line 247.
at /usr/share/perl5/File/Copy/Recursive.pm line 247.
File::Copy::Recursive::__ANON__("/var/www/foswiki/distro/core/data/Litterbox", "/var/www/foswiki/distro/core/data/Playground", undef) called at /usr/share/perl5/File/Copy/Recursive.pm line 273
File::Copy::Recursive::dircopy("/var/www/foswiki/distro/core/data/Litterbox", "/var/www/foswiki/distro/core/data/Playground") called at /usr/share/perl5/File/Copy/Recursive.pm line 97
File::Copy::Recursive::__ANON__(0, "/var/www/foswiki/distro/core/data/Litterbox", "/var/www/foswiki/distro/core/data/Playground") called at /usr/share/perl5/File/Copy/Recursive.pm line 292
File::Copy::Recursive::dirmove("/var/www/foswiki/distro/core/data/Litterbox", "/var/www/foswiki/distro/core/data/Playground") called at /var/www/foswiki/distro/core/lib/Foswiki/Store/PlainFile.pm line 1432
Foswiki::Store::PlainFile::_moveFile("/var/www/foswiki/distro/core/data/Litterbox", "/var/www/foswiki/distro/core/data/Playground") called at /var/www/foswiki/distro/core/lib/Foswiki/Store/PlainFile.pm line 325
Foswiki::Store::PlainFile::moveWeb(Foswiki::Store::PlainFile=HASH(0x32403d8), Foswiki::Meta=HASH(0x363cfc0), Foswiki::Meta=HASH(0x233fc80), "BaseUserMapping_333") called at /var/www/foswiki/distro/core/lib/Foswiki/Meta.pm line 2319
Foswiki::Meta::move(Foswiki::Meta=HASH(0x363cfc0), Foswiki::Meta=HASH(0x233fc80)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI/Rename.pm line 675
Foswiki::UI::Rename::__ANON__() called at /usr/share/perl5/Error.pm line 416
eval {...} called at /usr/share/perl5/Error.pm line 408
Error::subs::try(CODE(0x1c7f888), Foswiki::Meta=HASH(0x3a1ed90)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI/Rename.pm line 697
Foswiki::UI::Rename::_renameWeb(Foswiki=HASH(0x2baecb0), "Litterbox") called at /var/www/foswiki/distro/core/lib/Foswiki/UI/Rename.pm line 82
Foswiki::UI::Rename::rename(Foswiki=HASH(0x2baecb0)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 374
Foswiki::UI::__ANON__() called at /usr/share/perl5/Error.pm line 416
eval {...} called at /usr/share/perl5/Error.pm line 408
Error::subs::try(CODE(0x1903ae8), HASH(0x2b976d0)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 500
Foswiki::UI::_execute(Foswiki::Request=HASH(0x2979778), CODE(0x25bd7c8), "rename", 1) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 326
Foswiki::UI::handleRequest(Foswiki::Request=HASH(0x2979778)) called at /var/www/foswiki/distro/core/lib/Foswiki/Engine/CGI.pm line 99
Foswiki::Engine::CGI::run(Foswiki::Engine::CGI=HASH(0x22734d8)) called |
And the move issue.
| 2015-08-14T23:02:20-04:00 error | PlainFile: move /var/www/foswiki/distro/core/data/Litterbox to /var/www/foswiki/distro/core/data/Playground failed: Not a directory at /var/www/foswiki/distro/core/lib/Foswiki/Store/PlainFile.pm line 1437.
at /usr/share/perl5/CGI/Carp.pm line 353.
CGI::Carp::realdie("PlainFile: move /var/www/foswiki/distro/core/data/Litterbox t"...) called at /usr/share/perl5/CGI/Carp.pm line 443
CGI::Carp::die("PlainFile: move /var/www/foswiki/distro/core/data/Litterbox t"...) called at /var/www/foswiki/distro/core/lib/Foswiki/Store/PlainFile.pm line 1437
Foswiki::Store::PlainFile::_moveFile("/var/www/foswiki/distro/core/data/Litterbox", "/var/www/foswiki/distro/core/data/Playground") called at /var/www/foswiki/distro/core/lib/Foswiki/Store/PlainFile.pm line 325
Foswiki::Store::PlainFile::moveWeb(Foswiki::Store::PlainFile=HASH(0x38b1740), Foswiki::Meta=HASH(0x3da1470), Foswiki::Meta=HASH(0x29ac7c8), "BaseUserMapping_333") called at /var/www/foswiki/distro/core/lib/Foswiki/Meta.pm line 2319
Foswiki::Meta::move(Foswiki::Meta=HASH(0x3da1470), Foswiki::Meta=HASH(0x29ac7c8)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI/Rename.pm line 675
Foswiki::UI::Rename::__ANON__() called at /usr/share/perl5/Error.pm line 416
eval {...} called at /usr/share/perl5/Error.pm line 408
Error::subs::try(CODE(0x3d81cf0), Foswiki::Meta=HASH(0x40cde78)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI/Rename.pm line 697
Foswiki::UI::Rename::_renameWeb(Foswiki=HASH(0x31f9680), "Litterbox") called at /var/www/foswiki/distro/core/lib/Foswiki/UI/Rename.pm line 82
Foswiki::UI::Rename::rename(Foswiki=HASH(0x31f9680)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 374
Foswiki::UI::__ANON__() called at /usr/share/perl5/Error.pm line 416
eval {...} called at /usr/share/perl5/Error.pm line 408
Error::subs::try(CODE(0x1f9f9b0), HASH(0x31d61f8)) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 500
Foswiki::UI::_execute(Foswiki::Request=HASH(0x2fc8748), CODE(0x27cc870), "rename", 1) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 326
Foswiki::UI::handleRequest(Foswiki::Request=HASH(0x2fc8748)) called at /var/www/foswiki/distro/core/lib/Foswiki/Engine/CGI.pm line 99
Foswiki::Engine::CGI::run(Foswiki::Engine::CGI=HASH(0x28abc58)) called |
The rename works fine under the RCS store, no Taint or move erorrs.
--
GeorgeClark - 15 Aug 2015
I recreated this by pseudo-installing a local extension that added a web, which is symlinked. Then tried to rename it.
--
GeorgeClark - 15 Aug 2015
The following patch appears to work fine on Linux anyway. It renames the web, preserving the symlink.
diff --git a/PlainFileStoreContrib/lib/Foswiki/Store/PlainFile.pm b/PlainFileStoreContrib/lib/Foswiki/Store/PlainFile.pm
index 05a8409..010b4e8 100644
--- a/PlainFileStoreContrib/lib/Foswiki/Store/PlainFile.pm
+++ b/PlainFileStoreContrib/lib/Foswiki/Store/PlainFile.pm
@@ -1428,12 +1428,7 @@ sub _moveFile {
_mkPathTo($to);
my $ok;
my $efrom = _encode($from);
- if ( -d $efrom ) {
- $ok = File::Copy::Recursive::dirmove( $efrom, _encode($to) );
- }
- elsif ( -e $efrom ) {
- $ok = File::Copy::move( $efrom, _encode($to) );
- }
+ $ok = File::Copy::Recursive::rmove( $efrom, _encode($to) );
$ok or die "PlainFile: move $from to $to failed: $!";
}
--
GeorgeClark - 15 Aug 2015
The taint error is a red herring. For some reason on occasion a Meta object is not recognized as a meta object. I ran a Data::Dumper on the calls to
sub _getData()
and see the following:
Returning /var/www/foswiki/distro/core/data/.Foswiki::Meta=HASH(0x2bdcdb0)
$VAR1 = \'Foswiki::Meta=HASH(0x2bdcdb0)';
| 2015-08-14T23:37:25-04:00 error | Insecure dependency in symlink while running with -T switch at /usr/share/perl5/File/Copy/Recursive.pm line 151.
at /usr/share/perl5/File/Copy/Recursive.pm line 151.
File::Copy::Recursive::fcopy("/var/www/foswiki/distro/core/data/Playground", "/var/www/foswiki/distro/core/data/Foswiki::Meta=HASH(0x2bdcdb0)") called at /usr/share/perl5/File/Copy/Recursive.pm line 95
So the code treats the non-meta as a string, and the copy fails.
--
GeorgeClark - 15 Aug 2015
Crawford, setting this for your review. The above patch works for me.
--
GeorgeClark - 19 Aug 2015
Looks fine. The rationale for using File::Copy::Recursive was to avoid cross-filesystem issues, as you surmised.
--
Main.CrawfordCurrie - 20 Aug 2015 - 06:00