summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-02-15 21:58:29 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-02-15 21:58:29 +0000
commit8f1f5d8e3799254af76e7cb5eb33fbabed1d2082 (patch)
tree7c25dae902e133935f08bf0abaed47d813454e30
parentTest error cases (diff)
downloadnetfs-8f1f5d8e3799254af76e7cb5eb33fbabed1d2082.tar.bz2
netfs-8f1f5d8e3799254af76e7cb5eb33fbabed1d2082.tar.xz
netfs-8f1f5d8e3799254af76e7cb5eb33fbabed1d2082.zip
Test and fix rename behaviour
-rw-r--r--netfs/daemon/daemonVolume.cpp8
-rw-r--r--netfs/unittests/testCore.cpp16
2 files changed, 17 insertions, 7 deletions
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp
index 5064b5b..3ec6865 100644
--- a/netfs/daemon/daemonVolume.cpp
+++ b/netfs/daemon/daemonVolume.cpp
@@ -128,13 +128,7 @@ VolumeServer::rename(const NetFS::ReqEnv & re, const std::string & from, const s
boost::filesystem::path f(resolvePath(from));
boost::filesystem::path t(resolvePath(to));
mc.AssertWriteParent(f);
- mc.AssertWrite(f);
- if (boost::filesystem::is_directory(t)) {
- mc.AssertWrite(t);
- }
- else {
- mc.AssertWriteParent(t);
- }
+ mc.AssertWriteParent(t);
if (::rename(f.c_str(), t.c_str()) != 0) {
throw NetFS::SystemError(errno);
}
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index 59c7d70..0b5241d 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -294,6 +294,22 @@ BOOST_AUTO_TEST_CASE( mknod )
BOOST_REQUIRE_EQUAL(fuse->unlink("/nod"), -ENOENT);
}
+BOOST_AUTO_TEST_CASE( renameToDir )
+{
+ struct fuse_file_info fi;
+ memset(&fi, 0, sizeof(fi));
+ BOOST_REQUIRE_EQUAL(fuse->create("/file", 0600, &fi), 0);
+ BOOST_REQUIRE_EQUAL(fuse->release("/file", &fi), 0);
+ BOOST_REQUIRE_EQUAL(fuse->mkdir("/dir", 0000), 0);
+ BOOST_REQUIRE_EQUAL(fuse->rename("/file", "/dir/file"), -EACCES);
+ BOOST_REQUIRE_EQUAL(fuse->chmod("/dir", 0700), 0);
+ BOOST_REQUIRE_EQUAL(fuse->rename("/file", "/dir"), -EISDIR);
+ BOOST_REQUIRE_EQUAL(fuse->rename("/file", "/dir/file"), 0);
+ BOOST_REQUIRE_EQUAL(fuse->unlink("/file"), -ENOENT);
+ BOOST_REQUIRE_EQUAL(fuse->unlink("/dir/file"), 0);
+ BOOST_REQUIRE_EQUAL(fuse->rmdir("/dir"), 0);
+}
+
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE( testNoAuthNoPass )