From: František Dvořák Date: Sat, 19 Oct 2013 19:15:59 +0000 (+0200) Subject: Fix removeDir() - no metadata check just for checking cwd. X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=91ccad0ac40b6cc5a3711e924002a89beb94bfd9;p=dmlite-plugins-vfs.git Fix removeDir() - no metadata check just for checking cwd. --- diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index 4ccad7a..d664e72 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -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);