Fix removeDir() - no metadata check just for checking cwd.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sat, 19 Oct 2013 19:15:59 +0000 (21:15 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 10 Feb 2014 13:51:35 +0000 (14:51 +0100)
src/VfsNs.cpp

index 4ccad7a..d664e72 100644 (file)
@@ -830,7 +830,7 @@ void VfsCatalog::rename(const std::string& oldPath, const std::string& newPath)
 void VfsCatalog::removeDir(const std::string& path) throw (DmException)
 {
   char *cwd = NULL, *rmd = NULL;
-  std::string parentPath, name;
+  std::string parentPath, name, lpath;
 
   if (vfsCheckPermissions(path, S_IWRITE))
     vfsThrow(EACCES, "not enough permissions for '%s'", clientName.c_str());
@@ -852,17 +852,19 @@ void VfsCatalog::removeDir(const std::string& path) throw (DmException)
       vfsThrow(EACCES, "not enough permissions for '%s' to remove '%s'", clientName.c_str(), path.c_str());
   }
 
+  lpath = getLocalPath(path);
+
   // check if we are not removing current working directory
   cwd = get_current_dir_name();
   try {
-    changeDir(path);
+    wrapCall(::chdir(lpath.c_str()));
     rmd = get_current_dir_name();
     if (strcmp(cwd, rmd) == 0) {
       vfsThrow(EINVAL, "can not remove current working directory");
     }
     ::chdir(cwd);
     // OK, we can try to remove
-    wrapCall(rmdir(getLocalPath(path).c_str()));
+    wrapCall(rmdir(lpath.c_str()));
   } catch (...) {
     if (cwd) ::chdir(cwd);
     free(cwd);