From 91ccad0ac40b6cc5a3711e924002a89beb94bfd9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Sat, 19 Oct 2013 21:15:59 +0200 Subject: [PATCH] Fix removeDir() - no metadata check just for checking cwd. --- src/VfsNs.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); -- 1.8.2.3