diff options
Diffstat (limited to 'netfs/daemonMisc.cpp')
-rw-r--r-- | netfs/daemonMisc.cpp | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/netfs/daemonMisc.cpp b/netfs/daemonMisc.cpp index dfcf8bf..06ba166 100644 --- a/netfs/daemonMisc.cpp +++ b/netfs/daemonMisc.cpp @@ -3,26 +3,23 @@ #include <unistd.h> #include <sys/stat.h> #include <limits.h> -#include "daemonMisc.h" +#include "daemonFileSystem.h" extern std::map<Ice::Int, int> files; -MiscServer::MiscServer(DaemonGlobalStatePtr dgs) : - DaemonModule(dgs) -{ -} - Ice::Int -MiscServer::access(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) +FileSystemServer::access(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); return ::access((sess->exportCfg->root / path).string().c_str(), mode); } NetFSComms::Attr -MiscServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &) +FileSystemServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); struct stat s; if (::stat((sess->exportCfg->root / path).string().c_str(), &s) != 0) { throw NetFSComms::SystemError(errno); @@ -32,8 +29,8 @@ MiscServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, con a.inode = s.st_ino; a.mode = s.st_mode; a.links = s.st_nlink; - a.uid = s.st_uid; - a.gid = s.st_gid; + a.uid = entries.getUName(s.st_uid); + a.gid = entries.getGName(s.st_gid); a.rdev = s.st_rdev; a.size = s.st_size; a.blockSize = s.st_blksize; @@ -45,42 +42,46 @@ MiscServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, con } void -MiscServer::symlink(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) +FileSystemServer::symlink(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); errno = 0; - if (::symlink(path1.c_str(), path2.c_str()) != 0) { + if (::symlink((sess->exportCfg->root / path1).string().c_str(), (sess->exportCfg->root / path2).string().c_str()) != 0) { throw NetFSComms::SystemError(errno); } // s.replicatedRequest = true; } void -MiscServer::link(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) +FileSystemServer::link(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); errno = 0; - if (::link(path1.c_str(), path2.c_str()) != 0) { + if (::link((sess->exportCfg->root / path1).string().c_str(), (sess->exportCfg->root / path2).string().c_str()) != 0) { throw NetFSComms::SystemError(errno); } // s.replicatedRequest = true; } void -MiscServer::rename(const NetFSComms::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &) +FileSystemServer::rename(const NetFSComms::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); errno = 0; - if (::rename(from.c_str(), to.c_str()) != 0) { + if (::rename((sess->exportCfg->root / from).string().c_str(), (sess->exportCfg->root / to).string().c_str()) != 0) { throw NetFSComms::SystemError(errno); } // s.replicatedRequest = true; } std::string -MiscServer::readlink(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &) +FileSystemServer::readlink(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); errno = 0; char buf[PATH_MAX]; ssize_t rc = ::readlink((sess->exportCfg->root / path).string().c_str(), buf, PATH_MAX); @@ -91,9 +92,10 @@ MiscServer::readlink(const NetFSComms::ReqEnv & re, const std::string & path, co } void -MiscServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) +FileSystemServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); errno = 0; if (::chmod((sess->exportCfg->root / path).string().c_str(), mode) != 0) { throw NetFSComms::SystemError(errno); @@ -102,9 +104,10 @@ MiscServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path, Ice:: } void -MiscServer::chown(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &) +FileSystemServer::chown(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &) { SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); errno = 0; if (::chown((sess->exportCfg->root / path).string().c_str(), uid, gid) != 0) { throw NetFSComms::SystemError(errno); @@ -112,3 +115,21 @@ MiscServer::chown(const NetFSComms::ReqEnv & re, const std::string & path, Ice:: // s.replicatedRequest = true; } +void +FileSystemServer::utimens(const NetFSComms::ReqEnv & re, const std::string & path, + Ice::Long s0, Ice::Long ns0, Ice::Long s1, Ice::Long ns1, const Ice::Current&) +{ + SessionPtr sess(dgs->getSession(re.tok)); + TempPrivs tp(re, &entries); + errno = 0; + struct timespec times[2]; + times[0].tv_sec = s0; + times[0].tv_nsec = ns0; + times[1].tv_sec = s1; + times[1].tv_nsec = ns1; + if (::utimensat(0, (sess->exportCfg->root / path).string().c_str(), times, 0) != 0) { + throw NetFSComms::SystemError(errno); + } + // s.replicatedRequest = true; +} + |