diff options
Diffstat (limited to 'netfs/daemon/daemonVolume.cpp')
-rw-r--r-- | netfs/daemon/daemonVolume.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index 347dbe2..4b8fe29 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -18,8 +18,10 @@ extern std::map<Ice::Int, int> files; -VolumeServer::VolumeServer(const boost::filesystem::path & r) : - root(r) +VolumeServer::VolumeServer(const boost::filesystem::path & r, const EntCache<User> & u, const EntCache<Group> & g) : + root(r), + userLookup(u), + groupLookup(g) { } @@ -36,7 +38,7 @@ VolumeServer::disconnect(const Ice::Current & ice) Ice::Int VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); struct stat s; boost::filesystem::path p(resolvePath(path)); if (::stat(p.string().c_str(), &s) != 0) { @@ -47,13 +49,13 @@ VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::In return 0; } mc.AssertRead(p.parent_path()); - if (mode & R_OK && !ModeCheck::ReadableBy(s, mc.myu, mc.myg)) { + if (mode & R_OK && !mc.ReadableBy(s, mc.myu, mc.myg)) { return EACCES; } - if (mode & W_OK && !ModeCheck::WritableBy(s, mc.myu, mc.myg)) { + if (mode & W_OK && !mc.WritableBy(s, mc.myu, mc.myg)) { return EACCES; } - if (mode & X_OK && !ModeCheck::ExecutableBy(s, mc.myu, mc.myg)) { + if (mode & X_OK && !mc.ExecutableBy(s, mc.myu, mc.myg)) { return EACCES; } return 0; @@ -62,7 +64,7 @@ VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::In NetFS::Attr VolumeServer::getattr(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); struct stat s; boost::filesystem::path p(resolvePath(path)); mc.AssertRead(p.parent_path()); @@ -70,14 +72,14 @@ VolumeServer::getattr(const NetFS::ReqEnv & re, const std::string & path, const throw NetFS::SystemError(errno); } NetFS::Attr a; - a << StatSource { s, boost::bind(&UserEntCache::getName, &UserEntCache::instance, _1, _2), boost::bind(&GroupEntCache::getName, &GroupEntCache::instance, _1, _2) }; + a << StatSource { s, userLookup, groupLookup }; return a; } void VolumeServer::mknod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, Ice::Int dev, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p.parent_path()); @@ -89,7 +91,7 @@ VolumeServer::mknod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int void VolumeServer::symlink(const NetFS::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path2)); mc.AssertWrite(p.parent_path()); @@ -105,7 +107,7 @@ VolumeServer::symlink(const NetFS::ReqEnv & re, const std::string & path1, const void VolumeServer::link(const NetFS::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p1(resolvePath(path1)); boost::filesystem::path p2(resolvePath(path2)); @@ -121,7 +123,7 @@ VolumeServer::link(const NetFS::ReqEnv & re, const std::string & path1, const st void VolumeServer::rename(const NetFS::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path f(resolvePath(from)); boost::filesystem::path t(resolvePath(to)); @@ -141,7 +143,7 @@ VolumeServer::rename(const NetFS::ReqEnv & re, const std::string & from, const s std::string VolumeServer::readlink(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; char buf[PATH_MAX]; boost::filesystem::path p(resolvePath(path)); @@ -156,7 +158,7 @@ VolumeServer::readlink(const NetFS::ReqEnv & re, const std::string & path, const void VolumeServer::chmod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); @@ -168,7 +170,7 @@ VolumeServer::chmod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int void VolumeServer::chown(const NetFS::ReqEnv & re, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); @@ -181,7 +183,7 @@ void VolumeServer::utimens(const NetFS::ReqEnv & re, const std::string & path, Ice::Long s0, Ice::Long ns0, Ice::Long s1, Ice::Long ns1, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; struct timespec times[2]; times[0].tv_sec = s0; @@ -198,7 +200,7 @@ VolumeServer::utimens(const NetFS::ReqEnv & re, const std::string & path, NetFS::VFS VolumeServer::statfs(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; struct statvfs s; boost::filesystem::path p(resolvePath(path)); @@ -214,7 +216,7 @@ VolumeServer::statfs(const NetFS::ReqEnv & re, const std::string & path, const I void VolumeServer::truncate(const NetFS::ReqEnv & re, const std::string & path, Ice::Long size, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); @@ -226,7 +228,7 @@ VolumeServer::truncate(const NetFS::ReqEnv & re, const std::string & path, Ice:: void VolumeServer::unlink(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); @@ -245,7 +247,7 @@ VolumeServer::openReadOnly(const NetFS::ReqEnv & re, const std::string & path, I NetFS::FilePrx VolumeServer::open(const NetFS::ReqEnv & re, const std::string & path, Ice::Int flags, const Ice::Current & ice) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertRead(p); @@ -256,13 +258,13 @@ VolumeServer::open(const NetFS::ReqEnv & re, const std::string & path, Ice::Int if (fd == -1) { throw NetFS::SystemError(errno); } - return NetFS::FilePrx::checkedCast(ice.adapter->addWithUUID(new FileServer(fd))); + return NetFS::FilePrx::checkedCast(ice.adapter->addWithUUID(new FileServer(fd, userLookup, groupLookup))); } NetFS::FilePrx VolumeServer::create(const NetFS::ReqEnv & re, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current & ice) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p.parent_path()); @@ -275,13 +277,13 @@ VolumeServer::create(const NetFS::ReqEnv & re, const std::string & path, Ice::In ::unlink(p.string().c_str()); throw NetFS::SystemError(errno); } - return NetFS::FilePrx::checkedCast(ice.adapter->addWithUUID(new FileServer(fd))); + return NetFS::FilePrx::checkedCast(ice.adapter->addWithUUID(new FileServer(fd, userLookup, groupLookup))); } NetFS::DirectoryPrx VolumeServer::opendir(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current & ice) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertRead(p); @@ -295,7 +297,7 @@ VolumeServer::opendir(const NetFS::ReqEnv & re, const std::string & path, const void VolumeServer::mkdir(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p.parent_path()); @@ -311,7 +313,7 @@ VolumeServer::mkdir(const NetFS::ReqEnv & re, const std::string & path, Ice::Int void VolumeServer::rmdir(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current&) { - ModeCheck mc(re, root); + ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; boost::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); |