diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-02-15 20:10:51 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-02-15 20:10:51 +0000 |
commit | eff9c2c3055fdf900b7ad690b23eb53cd086608b (patch) | |
tree | 85cce29dc882e69136844b0bb80bcaa4352ffd42 | |
parent | Almost complete coverage of basic directory operations (diff) | |
download | netfs-eff9c2c3055fdf900b7ad690b23eb53cd086608b.tar.bz2 netfs-eff9c2c3055fdf900b7ad690b23eb53cd086608b.tar.xz netfs-eff9c2c3055fdf900b7ad690b23eb53cd086608b.zip |
Enforce O_EXCL on create
-rw-r--r-- | netfs/daemon/daemonVolume.cpp | 2 | ||||
-rw-r--r-- | netfs/unittests/testCore.cpp | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index 2d67272..e4c65bd 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -262,7 +262,7 @@ VolumeServer::create(const NetFS::ReqEnv & re, const std::string & path, Ice::In errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWriteParent(p); - int fd = ::open(p.c_str(), O_CREAT | flags, mode); + int fd = ::open(p.c_str(), O_CREAT | O_EXCL | flags, mode); if (fd == -1) { throw NetFS::SystemError(errno); } diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp index 9610111..e933027 100644 --- a/netfs/unittests/testCore.cpp +++ b/netfs/unittests/testCore.cpp @@ -122,14 +122,12 @@ BOOST_AUTO_TEST_CASE( testSandboxing ) BOOST_REQUIRE(!boost::filesystem::exists(binDir / "outside")); BOOST_REQUIRE_EQUAL(fuse->create("/../sub/../outside", 0666, &fi), -EPERM); BOOST_REQUIRE(!boost::filesystem::exists(binDir / "outside")); - int fd = fuse->create("/inside", 0666, &fi); - BOOST_REQUIRE(fd >= 0); - fuse->release("/inside", &fi); - BOOST_REQUIRE(boost::filesystem::exists(binDir / testExport / "inside")); - int fd2 = fuse->create("inside", 0666, &fi); - BOOST_REQUIRE(fd2 >= 0); - fuse->release("inside", &fi); + BOOST_REQUIRE_EQUAL(fuse->create("/inside", 0666, &fi), 0); + BOOST_REQUIRE_EQUAL(fuse->release("/inside", &fi), 0); BOOST_REQUIRE(boost::filesystem::exists(binDir / testExport / "inside")); + BOOST_REQUIRE_EQUAL(fuse->create("inside2", 0666, &fi), 0); + BOOST_REQUIRE_EQUAL(fuse->release("inside2", &fi), 0); + BOOST_REQUIRE(boost::filesystem::exists(binDir / testExport / "inside2")); } int |