summaryrefslogtreecommitdiff
path: root/netfs/daemonMisc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netfs/daemonMisc.cpp')
-rw-r--r--netfs/daemonMisc.cpp56
1 files changed, 38 insertions, 18 deletions
diff --git a/netfs/daemonMisc.cpp b/netfs/daemonMisc.cpp
index 37c38c5..9b76d8e 100644
--- a/netfs/daemonMisc.cpp
+++ b/netfs/daemonMisc.cpp
@@ -11,18 +11,22 @@ extern std::map<Ice::Int, int> files;
Ice::Int
FileSystemServer::access(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
- return ::access((sess->exportCfg->root / path).string().c_str(), mode);
+ boost::filesystem::path p = sess->exportCfg->root / path;
+ sess.unlock();
+ return ::access(p.string().c_str(), mode);
}
NetFSComms::Attr
FileSystemServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
struct stat s;
- if (::lstat((sess->exportCfg->root / path).string().c_str(), &s) != 0) {
+ boost::filesystem::path p = sess->exportCfg->root / path;
+ sess.unlock();
+ if (::lstat(p.string().c_str(), &s) != 0) {
throw NetFSComms::SystemError(errno);
}
NetFSComms::Attr a;
@@ -45,10 +49,12 @@ FileSystemServer::getattr(const NetFSComms::ReqEnv & re, const std::string & pat
void
FileSystemServer::symlink(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
- if (::symlink(path1.c_str(), (sess->exportCfg->root / path2).string().c_str()) != 0) {
+ boost::filesystem::path p = sess->exportCfg->root / path2;
+ sess.unlock();
+ if (::symlink(path1.c_str(), p.string().c_str()) != 0) {
throw NetFSComms::SystemError(errno);
}
// s.replicatedRequest = true;
@@ -57,10 +63,13 @@ FileSystemServer::symlink(const NetFSComms::ReqEnv & re, const std::string & pat
void
FileSystemServer::link(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
- if (::link((sess->exportCfg->root / path1).string().c_str(), (sess->exportCfg->root / path2).string().c_str()) != 0) {
+ boost::filesystem::path p1 = sess->exportCfg->root / path1;
+ boost::filesystem::path p2 = sess->exportCfg->root / path2;
+ sess.unlock();
+ if (::link(p1.string().c_str(), p2.string().c_str()) != 0) {
throw NetFSComms::SystemError(errno);
}
// s.replicatedRequest = true;
@@ -69,10 +78,13 @@ FileSystemServer::link(const NetFSComms::ReqEnv & re, const std::string & path1,
void
FileSystemServer::rename(const NetFSComms::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
- if (::rename((sess->exportCfg->root / from).string().c_str(), (sess->exportCfg->root / to).string().c_str()) != 0) {
+ boost::filesystem::path f = sess->exportCfg->root / from;
+ boost::filesystem::path t = sess->exportCfg->root / to;
+ sess.unlock();
+ if (::rename(f.string().c_str(), t.string().c_str()) != 0) {
throw NetFSComms::SystemError(errno);
}
// s.replicatedRequest = true;
@@ -81,11 +93,13 @@ FileSystemServer::rename(const NetFSComms::ReqEnv & re, const std::string & from
std::string
FileSystemServer::readlink(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
char buf[PATH_MAX];
- ssize_t rc = ::readlink((sess->exportCfg->root / path).string().c_str(), buf, PATH_MAX);
+ boost::filesystem::path p = sess->exportCfg->root / path;
+ sess.unlock();
+ ssize_t rc = ::readlink(p.string().c_str(), buf, PATH_MAX);
if (rc == -1) {
throw NetFSComms::SystemError(errno);
}
@@ -95,10 +109,12 @@ FileSystemServer::readlink(const NetFSComms::ReqEnv & re, const std::string & pa
void
FileSystemServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(re.tok));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
- if (::chmod((sess->exportCfg->root / path).string().c_str(), mode) != 0) {
+ boost::filesystem::path p = sess->exportCfg->root / path;
+ sess.unlock();
+ if (::chmod(p.string().c_str(), mode) != 0) {
throw NetFSComms::SystemError(errno);
}
// s.replicatedRequest = true;
@@ -107,10 +123,12 @@ FileSystemServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path,
void
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));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
- if (::chown((sess->exportCfg->root / path).string().c_str(), uid, gid) != 0) {
+ boost::filesystem::path p = sess->exportCfg->root / path;
+ sess.unlock();
+ if (::chown(p.string().c_str(), uid, gid) != 0) {
throw NetFSComms::SystemError(errno);
}
// s.replicatedRequest = true;
@@ -120,7 +138,7 @@ 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));
+ SessionPtr sess(dgs->getSession(re.tok), true);
TempPrivs tp(re, &uentries, &gentries);
errno = 0;
struct timespec times[2];
@@ -128,7 +146,9 @@ FileSystemServer::utimens(const NetFSComms::ReqEnv & re, const std::string & pat
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, AT_SYMLINK_NOFOLLOW) != 0) {
+ boost::filesystem::path p = sess->exportCfg->root / path;
+ sess.unlock();
+ if (::utimensat(0, p.string().c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
throw NetFSComms::SystemError(errno);
}
// s.replicatedRequest = true;