summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-10-23 02:18:23 +0000
committerrandomdan <randomdan@localhost>2010-10-23 02:18:23 +0000
commitb53eef3844086aad1686091eafa3bcdf060802fb (patch)
tree23e19d213090b5895c32a356f350581a83fe252e
parentInitialise the IC after fuse forks, fixes whatever the hell it is that stops ... (diff)
downloadnetfs-b53eef3844086aad1686091eafa3bcdf060802fb.tar.bz2
netfs-b53eef3844086aad1686091eafa3bcdf060802fb.tar.xz
netfs-b53eef3844086aad1686091eafa3bcdf060802fb.zip
Send a request environment object container the auth token, and now with context user and group
-rw-r--r--netfs/daemonDirs.cpp12
-rw-r--r--netfs/daemonDirs.h6
-rw-r--r--netfs/daemonFiles.cpp24
-rw-r--r--netfs/daemonFiles.h12
-rw-r--r--netfs/daemonMisc.cpp32
-rw-r--r--netfs/daemonMisc.h16
-rw-r--r--netfs/daemonSystem.cpp4
-rw-r--r--netfs/daemonSystem.h2
-rw-r--r--netfs/fuse.cpp42
-rw-r--r--netfs/fuse.h10
-rw-r--r--netfs/fuseDirs.cpp6
-rw-r--r--netfs/fuseFiles.cpp12
-rw-r--r--netfs/fuseMisc.cpp16
-rw-r--r--netfs/fuseSystem.cpp2
-rw-r--r--netfs/netfsComms.ice41
15 files changed, 147 insertions, 90 deletions
diff --git a/netfs/daemonDirs.cpp b/netfs/daemonDirs.cpp
index c24dd9f..7533f61 100644
--- a/netfs/daemonDirs.cpp
+++ b/netfs/daemonDirs.cpp
@@ -11,9 +11,9 @@ DirsServer::DirsServer(DaemonGlobalStatePtr dgs) :
}
Ice::Int
-DirsServer::opendir(Ice::Long tok, const std::string & path, const Ice::Current&)
+DirsServer::opendir(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
DIR * od = ::opendir((sess->exportCfg->root / path).string().c_str());
if (!od) {
@@ -59,9 +59,9 @@ DirsServer::readdir(Ice::Long tok, Ice::Int id, const Ice::Current&)
}
void
-DirsServer::mkdir(Ice::Long tok, const std::string & path, Ice::Int mode, const Ice::Current&)
+DirsServer::mkdir(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::mkdir((sess->exportCfg->root / path).string().c_str(), mode) != 0) {
throw NetFSComms::SystemError(errno);
@@ -70,9 +70,9 @@ DirsServer::mkdir(Ice::Long tok, const std::string & path, Ice::Int mode, const
}
void
-DirsServer::rmdir(Ice::Long tok, const std::string & path, const Ice::Current&)
+DirsServer::rmdir(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::rmdir((sess->exportCfg->root / path).string().c_str()) != 0) {
throw NetFSComms::SystemError(errno);
diff --git a/netfs/daemonDirs.h b/netfs/daemonDirs.h
index 1d5e2b5..29e343a 100644
--- a/netfs/daemonDirs.h
+++ b/netfs/daemonDirs.h
@@ -9,12 +9,12 @@ class DirsServer : public DaemonModule, public NetFSComms::Dirs {
public:
DirsServer(DaemonGlobalStatePtr dgs);
- virtual Ice::Int opendir(Ice::Long tok, const std::string & path, const Ice::Current&);
+ virtual Ice::Int opendir(const NetFSComms::ReqEnv &, const std::string & path, const Ice::Current&);
virtual void closedir(Ice::Long tok, Ice::Int id, const Ice::Current&);
virtual NetFSComms::NameList readdir(Ice::Long tok, Ice::Int id, const Ice::Current&);
- virtual void mkdir(Ice::Long tok, const std::string & path, Ice::Int id, const Ice::Current&);
- virtual void rmdir(Ice::Long tok, const std::string & path, const Ice::Current&);
+ virtual void mkdir(const NetFSComms::ReqEnv &, const std::string & path, Ice::Int id, const Ice::Current&);
+ virtual void rmdir(const NetFSComms::ReqEnv &, const std::string & path, const Ice::Current&);
private:
};
diff --git a/netfs/daemonFiles.cpp b/netfs/daemonFiles.cpp
index 826f7be..c6e8a00 100644
--- a/netfs/daemonFiles.cpp
+++ b/netfs/daemonFiles.cpp
@@ -10,9 +10,9 @@ FileServer::FileServer(DaemonGlobalStatePtr dgs) :
}
void
-FileServer::truncate(Ice::Long tok, const std::string & path, Ice::Long size, const Ice::Current&)
+FileServer::truncate(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Long size, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::truncate((sess->exportCfg->root / path).string().c_str(), size) != 0) {
throw NetFSComms::SystemError(errno);
@@ -21,9 +21,9 @@ FileServer::truncate(Ice::Long tok, const std::string & path, Ice::Long size, co
}
void
-FileServer::ftruncate(Ice::Long tok, Ice::Int id, Ice::Long size, const Ice::Current&)
+FileServer::ftruncate(const NetFSComms::ReqEnv & re, Ice::Int id, Ice::Long size, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
if (sess->files.find(id) == sess->files.end()) {
throw NetFSComms::SystemError(EBADF);
}
@@ -35,9 +35,9 @@ FileServer::ftruncate(Ice::Long tok, Ice::Int id, Ice::Long size, const Ice::Cur
}
NetFSComms::Attr
-FileServer::fgetattr(Ice::Long tok, Ice::Int id, const Ice::Current &)
+FileServer::fgetattr(const NetFSComms::ReqEnv & re, Ice::Int id, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
if (sess->files.find(id) == sess->files.end()) {
throw NetFSComms::SystemError(EBADF);
}
@@ -63,9 +63,9 @@ FileServer::fgetattr(Ice::Long tok, Ice::Int id, const Ice::Current &)
}
void
-FileServer::unlink(Ice::Long tok, const std::string & path, const Ice::Current&)
+FileServer::unlink(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::unlink((sess->exportCfg->root / path).string().c_str()) != 0) {
throw NetFSComms::SystemError(errno);
@@ -74,9 +74,9 @@ FileServer::unlink(Ice::Long tok, const std::string & path, const Ice::Current&)
}
Ice::Int
-FileServer::open(Ice::Long tok, const std::string & path, Ice::Int flags, const Ice::Current&)
+FileServer::open(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int flags, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
int fd = ::open((sess->exportCfg->root / path).string().c_str(), flags);
if (fd == -1) {
@@ -88,9 +88,9 @@ FileServer::open(Ice::Long tok, const std::string & path, Ice::Int flags, const
}
Ice::Int
-FileServer::create(Ice::Long tok, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current&)
+FileServer::create(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
int fd = ::open((sess->exportCfg->root / path).string().c_str(), O_CREAT | flags, mode);
if (fd == -1) {
diff --git a/netfs/daemonFiles.h b/netfs/daemonFiles.h
index be3de2d..3c5db92 100644
--- a/netfs/daemonFiles.h
+++ b/netfs/daemonFiles.h
@@ -8,14 +8,14 @@ class FileServer : public DaemonModule, public NetFSComms::Files {
public:
FileServer(DaemonGlobalStatePtr dgs);
- virtual void truncate(Ice::Long tok, const std::string & path, Ice::Long size, const Ice::Current&);
- virtual void ftruncate(Ice::Long tok, Ice::Int id, Ice::Long size, const Ice::Current&);
- virtual NetFSComms::Attr fgetattr(Ice::Long tok, Ice::Int id, const Ice::Current&);
+ virtual void truncate(const NetFSComms::ReqEnv &, const std::string & path, Ice::Long size, const Ice::Current&);
+ virtual void ftruncate(const NetFSComms::ReqEnv &, Ice::Int id, Ice::Long size, const Ice::Current&);
+ virtual NetFSComms::Attr fgetattr(const NetFSComms::ReqEnv &, Ice::Int id, const Ice::Current&);
- virtual void unlink(Ice::Long tok, const std::string & path, const Ice::Current&);
+ virtual void unlink(const NetFSComms::ReqEnv &, const std::string & path, const Ice::Current&);
- virtual Ice::Int open(Ice::Long tok, const std::string & path, Ice::Int flags, const Ice::Current&);
- virtual Ice::Int create(Ice::Long tok, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current&);
+ virtual Ice::Int open(const NetFSComms::ReqEnv &, const std::string & path, Ice::Int flags, const Ice::Current&);
+ virtual Ice::Int create(const NetFSComms::ReqEnv &, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current&);
virtual void close(Ice::Long tok, Ice::Int id, const Ice::Current&);
virtual NetFSComms::Buffer read(Ice::Long tok, Ice::Int id, Ice::Long offset, Ice::Long size, const Ice::Current&);
virtual void write(Ice::Long tok, Ice::Int id, Ice::Long offset, Ice::Long size, const NetFSComms::Buffer & data, const Ice::Current&);
diff --git a/netfs/daemonMisc.cpp b/netfs/daemonMisc.cpp
index 4fa6eaf..dfcf8bf 100644
--- a/netfs/daemonMisc.cpp
+++ b/netfs/daemonMisc.cpp
@@ -13,16 +13,16 @@ MiscServer::MiscServer(DaemonGlobalStatePtr dgs) :
}
Ice::Int
-MiscServer::access(Ice::Long tok, const std::string & path, Ice::Int mode, const Ice::Current &)
+MiscServer::access(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
return ::access((sess->exportCfg->root / path).string().c_str(), mode);
}
NetFSComms::Attr
-MiscServer::getattr(Ice::Long tok, const std::string & path, const Ice::Current &)
+MiscServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
struct stat s;
if (::stat((sess->exportCfg->root / path).string().c_str(), &s) != 0) {
throw NetFSComms::SystemError(errno);
@@ -45,9 +45,9 @@ MiscServer::getattr(Ice::Long tok, const std::string & path, const Ice::Current
}
void
-MiscServer::symlink(Ice::Long tok, const std::string & path1, const std::string & path2, const Ice::Current &)
+MiscServer::symlink(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::symlink(path1.c_str(), path2.c_str()) != 0) {
throw NetFSComms::SystemError(errno);
@@ -56,9 +56,9 @@ MiscServer::symlink(Ice::Long tok, const std::string & path1, const std::string
}
void
-MiscServer::link(Ice::Long tok, const std::string & path1, const std::string & path2, const Ice::Current &)
+MiscServer::link(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::link(path1.c_str(), path2.c_str()) != 0) {
throw NetFSComms::SystemError(errno);
@@ -67,9 +67,9 @@ MiscServer::link(Ice::Long tok, const std::string & path1, const std::string & p
}
void
-MiscServer::rename(Ice::Long tok, const std::string & from, const std::string & to, const Ice::Current &)
+MiscServer::rename(const NetFSComms::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::rename(from.c_str(), to.c_str()) != 0) {
throw NetFSComms::SystemError(errno);
@@ -78,9 +78,9 @@ MiscServer::rename(Ice::Long tok, const std::string & from, const std::string &
}
std::string
-MiscServer::readlink(Ice::Long tok, const std::string & path, const Ice::Current &)
+MiscServer::readlink(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
char buf[PATH_MAX];
ssize_t rc = ::readlink((sess->exportCfg->root / path).string().c_str(), buf, PATH_MAX);
@@ -91,9 +91,9 @@ MiscServer::readlink(Ice::Long tok, const std::string & path, const Ice::Current
}
void
-MiscServer::chmod(Ice::Long tok, const std::string & path, Ice::Int mode, const Ice::Current &)
+MiscServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::chmod((sess->exportCfg->root / path).string().c_str(), mode) != 0) {
throw NetFSComms::SystemError(errno);
@@ -102,9 +102,9 @@ MiscServer::chmod(Ice::Long tok, const std::string & path, Ice::Int mode, const
}
void
-MiscServer::chown(Ice::Long tok, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &)
+MiscServer::chown(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
if (::chown((sess->exportCfg->root / path).string().c_str(), uid, gid) != 0) {
throw NetFSComms::SystemError(errno);
diff --git a/netfs/daemonMisc.h b/netfs/daemonMisc.h
index 3682baf..1d9336a 100644
--- a/netfs/daemonMisc.h
+++ b/netfs/daemonMisc.h
@@ -8,14 +8,14 @@ class MiscServer : public DaemonModule, public NetFSComms::Misc {
public:
MiscServer(DaemonGlobalStatePtr dgs);
- virtual Ice::Int access(Ice::Long tok, const std::string & path, Ice::Int mode, const Ice::Current&);
- virtual NetFSComms::Attr getattr(Ice::Long tok, const std::string & path, const Ice::Current&);
- virtual void symlink(Ice::Long tok, const std::string & path1, const std::string & path2, const Ice::Current&);
- virtual void link(Ice::Long tok, const std::string & path1, const std::string & path2, const Ice::Current&);
- virtual void rename(Ice::Long tok, const std::string & path1, const std::string & path2, const Ice::Current&);
- virtual std::string readlink(Ice::Long tok, const std::string & path, const Ice::Current&);
- virtual void chmod(Ice::Long tok, const std::string & path, Ice::Int mode, const Ice::Current&);
- virtual void chown(Ice::Long tok, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current&);
+ virtual Ice::Int access(const NetFSComms::ReqEnv &, const std::string & path, Ice::Int mode, const Ice::Current&);
+ virtual NetFSComms::Attr getattr(const NetFSComms::ReqEnv &, const std::string & path, const Ice::Current&);
+ virtual void symlink(const NetFSComms::ReqEnv &, const std::string & path1, const std::string & path2, const Ice::Current&);
+ virtual void link(const NetFSComms::ReqEnv &, const std::string & path1, const std::string & path2, const Ice::Current&);
+ virtual void rename(const NetFSComms::ReqEnv &, const std::string & path1, const std::string & path2, const Ice::Current&);
+ virtual std::string readlink(const NetFSComms::ReqEnv &, const std::string & path, const Ice::Current&);
+ virtual void chmod(const NetFSComms::ReqEnv &, const std::string & path, Ice::Int mode, const Ice::Current&);
+ virtual void chown(const NetFSComms::ReqEnv &, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current&);
};
#endif
diff --git a/netfs/daemonSystem.cpp b/netfs/daemonSystem.cpp
index fa9cb1d..cb3b6d1 100644
--- a/netfs/daemonSystem.cpp
+++ b/netfs/daemonSystem.cpp
@@ -9,9 +9,9 @@ SystemServer::SystemServer(DaemonGlobalStatePtr dgs) :
}
NetFSComms::VFS
-SystemServer::statfs(Ice::Long tok, const std::string & path, const Ice::Current&)
+SystemServer::statfs(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current&)
{
- SessionPtr sess(dgs->getSession(tok));
+ SessionPtr sess(dgs->getSession(re.tok));
errno = 0;
struct statvfs s;
if (::statvfs((sess->exportCfg->root / path).string().c_str(), &s) != 0) {
diff --git a/netfs/daemonSystem.h b/netfs/daemonSystem.h
index 48670fc..e42484a 100644
--- a/netfs/daemonSystem.h
+++ b/netfs/daemonSystem.h
@@ -8,7 +8,7 @@ class SystemServer : public DaemonModule, public NetFSComms::System {
public:
SystemServer(DaemonGlobalStatePtr dgs);
- virtual NetFSComms::VFS statfs(Ice::Long tok, const std::string & path, const Ice::Current&);
+ virtual NetFSComms::VFS statfs(const NetFSComms::ReqEnv &, const std::string & path, const Ice::Current&);
};
#endif
diff --git a/netfs/fuse.cpp b/netfs/fuse.cpp
index b0bfa03..faa2c65 100644
--- a/netfs/fuse.cpp
+++ b/netfs/fuse.cpp
@@ -5,11 +5,16 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <pwd.h>
+#include <grp.h>
#include "fuse.h"
#include "fuseConfig.h"
static FuseAppBase * fuseApp;
+std::map<uid_t, std::string> NetFS::ReqEnv::uidcache;
+std::map<gid_t, std::string> NetFS::ReqEnv::gidcache;
+
template <class A, int (FuseAppBase::*f)(A)>
static int fuseCall(A a)
{
@@ -89,6 +94,43 @@ NetFS::opt_parse(void *, const char * arg, int key, struct fuse_args *)
return 1;
}
+NetFS::ReqEnv
+NetFS::reqEnv() const
+{
+ return ReqEnv(authtok);
+}
+
+void
+NetFS::ReqEnv::makeugidCache()
+{
+ setpwent();
+ while (struct passwd * pwp = getpwent()) {
+ uidcache[pwp->pw_uid] = pwp->pw_name;
+ }
+ endpwent();
+ setgrent();
+ while (struct group * grpp = getgrent()) {
+ gidcache[grpp->gr_gid] = grpp->gr_name;
+ }
+ endgrent();
+}
+
+NetFS::ReqEnv::ReqEnv(Ice::Long at)
+{
+ struct fuse_context * c = fuse_get_context();
+ std::map<uid_t, std::string>::const_iterator u = uidcache.find(c->uid);
+ std::map<gid_t, std::string>::const_iterator g = gidcache.find(c->gid);
+ if (u == uidcache.end() || g == gidcache.end()) {
+ makeugidCache();
+ if ((u = uidcache.find(c->uid)) == uidcache.end() || (g = gidcache.find(c->gid)) == gidcache.end()) {
+ throw NetFSComms::SystemError(EPERM);
+ }
+ }
+ tok = at;
+ user = u->second;
+ grp = g->second;
+}
+
NetFS::NetFS(int & argc, char ** argv) :
_argc(argc),
_argv(argv),
diff --git a/netfs/fuse.h b/netfs/fuse.h
index bfe9335..6bcc3ae 100644
--- a/netfs/fuse.h
+++ b/netfs/fuse.h
@@ -8,6 +8,14 @@
class NetFS : public FuseAppBase
{
public:
+ class ReqEnv : public NetFSComms::ReqEnv {
+ public:
+ ReqEnv(Ice::Long at);
+ private:
+ static std::map<uid_t, std::string> uidcache;
+ static std::map<gid_t, std::string> gidcache;
+ static void makeugidCache();
+ };
NetFS(int & argc, char ** argv);
~NetFS();
private:
@@ -42,6 +50,8 @@ class NetFS : public FuseAppBase
int statfs(const char *, struct statvfs *);
// stuff
+ ReqEnv reqEnv() const;
+
int & _argc;
char ** _argv;
Ice::CommunicatorPtr ic;
diff --git a/netfs/fuseDirs.cpp b/netfs/fuseDirs.cpp
index 9d3861e..a93d7a3 100644
--- a/netfs/fuseDirs.cpp
+++ b/netfs/fuseDirs.cpp
@@ -5,7 +5,7 @@ int
NetFS::opendir(const char * p, struct fuse_file_info * fi)
{
try {
- fi->fh = dirs->opendir(authtok, p);
+ fi->fh = dirs->opendir(reqEnv(), p);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -44,7 +44,7 @@ int
NetFS::mkdir(const char * p, mode_t m)
{
try {
- dirs->mkdir(authtok, p, m);
+ dirs->mkdir(reqEnv(), p, m);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -55,7 +55,7 @@ int
NetFS::rmdir(const char * p)
{
try {
- dirs->rmdir(authtok, p);
+ dirs->rmdir(reqEnv(), p);
return 0;
}
catch (NetFSComms::SystemError & e) {
diff --git a/netfs/fuseFiles.cpp b/netfs/fuseFiles.cpp
index 5eb3bd5..c92f86c 100644
--- a/netfs/fuseFiles.cpp
+++ b/netfs/fuseFiles.cpp
@@ -5,7 +5,7 @@ int
NetFS::open(const char * p, struct fuse_file_info * fi)
{
try {
- fi->fh = files->open(authtok, p, fi->flags);
+ fi->fh = files->open(reqEnv(), p, fi->flags);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -17,7 +17,7 @@ int
NetFS::create(const char * p, mode_t m, struct fuse_file_info * fi)
{
try {
- fi->fh = files->create(authtok, p, 0, m);
+ fi->fh = files->create(reqEnv(), p, 0, m);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -69,7 +69,7 @@ int
NetFS::truncate(const char * p, off_t o)
{
try {
- files->truncate(authtok, p, o);
+ files->truncate(reqEnv(), p, o);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -81,7 +81,7 @@ int
NetFS::ftruncate(const char *, off_t o, fuse_file_info * fi)
{
try {
- files->ftruncate(authtok, fi->fh, o);
+ files->ftruncate(reqEnv(), fi->fh, o);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -93,7 +93,7 @@ int
NetFS::fgetattr(const char *, struct stat * s, fuse_file_info * fi)
{
try {
- NetFSComms::Attr a = files->fgetattr(authtok, fi->fh);
+ NetFSComms::Attr a = files->fgetattr(reqEnv(), fi->fh);
s->st_dev = a.dev;
s->st_ino = a.inode;
s->st_mode = a.mode;
@@ -118,7 +118,7 @@ int
NetFS::unlink(const char * p)
{
try {
- files->unlink(authtok, p);
+ files->unlink(reqEnv(), p);
return 0;
}
catch (NetFSComms::SystemError & e) {
diff --git a/netfs/fuseMisc.cpp b/netfs/fuseMisc.cpp
index 52350e1..cf7e551 100644
--- a/netfs/fuseMisc.cpp
+++ b/netfs/fuseMisc.cpp
@@ -4,13 +4,13 @@
int
NetFS::access(const char * p, int a)
{
- return -misc->access(authtok, p, a);
+ return -misc->access(reqEnv(), p, a);
}
int
NetFS::getattr(const char * p, struct stat * s)
{
try {
- NetFSComms::Attr a = misc->getattr(authtok, p);
+ NetFSComms::Attr a = misc->getattr(reqEnv(), p);
s->st_dev = a.dev;
s->st_ino = a.inode;
s->st_mode = a.mode;
@@ -35,7 +35,7 @@ int
NetFS::chmod(const char * p, mode_t m)
{
try {
- misc->chmod(authtok, p, m);
+ misc->chmod(reqEnv(), p, m);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -47,7 +47,7 @@ int
NetFS::chown(const char * p, uid_t u, gid_t g)
{
try {
- misc->chown(authtok, p, u, g);
+ misc->chown(reqEnv(), p, u, g);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -59,7 +59,7 @@ int
NetFS::link(const char * p1, const char * p2)
{
try {
- misc->link(authtok, p1, p2);
+ misc->link(reqEnv(), p1, p2);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -71,7 +71,7 @@ int
NetFS::symlink(const char * p1, const char * p2)
{
try {
- misc->symlink(authtok, p1, p2);
+ misc->symlink(reqEnv(), p1, p2);
return 0;
}
catch (NetFSComms::SystemError & e) {
@@ -83,7 +83,7 @@ int
NetFS::readlink(const char * p, char * p2, size_t s)
{
try {
- std::string l = misc->readlink(authtok, p);
+ std::string l = misc->readlink(reqEnv(), p);
l.copy(p2, s);
p2[s] = '\0';
return 0;
@@ -97,7 +97,7 @@ int
NetFS::rename(const char * p1, const char * p2)
{
try {
- misc->rename(authtok, p1, p2);
+ misc->rename(reqEnv(), p1, p2);
return 0;
}
catch (NetFSComms::SystemError & e) {
diff --git a/netfs/fuseSystem.cpp b/netfs/fuseSystem.cpp
index 5cdc462..c05ac22 100644
--- a/netfs/fuseSystem.cpp
+++ b/netfs/fuseSystem.cpp
@@ -4,7 +4,7 @@ int
NetFS::statfs(const char * p, struct statvfs * vfs)
{
try {
- NetFSComms::VFS v = system->statfs(authtok, p);
+ NetFSComms::VFS v = system->statfs(reqEnv(), p);
vfs->f_bsize = v.blockSize;
vfs->f_frsize = v.fragmentSize;
vfs->f_blocks = v.blocks;
diff --git a/netfs/netfsComms.ice b/netfs/netfsComms.ice
index 058412a..c4e5c4f 100644
--- a/netfs/netfsComms.ice
+++ b/netfs/netfsComms.ice
@@ -36,43 +36,48 @@ module NetFSComms {
long mtime;
long ctime;
};
+ struct ReqEnv {
+ string user;
+ string grp;
+ long tok;
+ };
sequence<byte> Buffer;
sequence<string> NameList;
// Interfaces
interface Files {
- idempotent void truncate(long tok, string path, long size) throws AuthError, SystemError;
- idempotent void ftruncate(long tok, int id, long size) throws AuthError, SystemError;
- idempotent Attr fgetattr(long tok, int id) throws AuthError, SystemError;
+ idempotent void truncate(ReqEnv env, string path, long size) throws AuthError, SystemError;
+ idempotent void ftruncate(ReqEnv env, int id, long size) throws AuthError, SystemError;
+ idempotent Attr fgetattr(ReqEnv env, int id) throws AuthError, SystemError;
- void unlink(long tok, string path) throws AuthError, SystemError;
+ void unlink(ReqEnv env, string path) throws AuthError, SystemError;
- int open(long tok, string path, int flags) throws AuthError, SystemError;
- int create(long tok, string path, int flags, int mode) throws AuthError, SystemError;
+ int open(ReqEnv env, string path, int flags) throws AuthError, SystemError;
+ int create(ReqEnv env, string path, int flags, int mode) throws AuthError, SystemError;
void close(long tok, int id) throws AuthError, SystemError;
idempotent Buffer read(long tok, int id, long offset, long size) throws AuthError, SystemError;
idempotent void write(long tok, int id, long offset, long size, Buffer data) throws AuthError, SystemError;
};
interface Dirs {
- int opendir(long tok, string path) throws AuthError, SystemError;
+ int opendir(ReqEnv env, string path) throws AuthError, SystemError;
void closedir(long tok, int id) throws AuthError, SystemError;
idempotent NameList readdir(long tok, int id) throws AuthError, SystemError;
- void mkdir(long tok, string path, int mode) throws AuthError, SystemError;
- void rmdir(long tok, string path) throws AuthError, SystemError;
+ void mkdir(ReqEnv env, string path, int mode) throws AuthError, SystemError;
+ void rmdir(ReqEnv env, string path) throws AuthError, SystemError;
};
interface System {
- idempotent VFS statfs(long tok, string path) throws AuthError, SystemError;
+ idempotent VFS statfs(ReqEnv env, string path) throws AuthError, SystemError;
};
interface Misc {
- idempotent int access(long tok, string path, int mode) throws AuthError, SystemError;
- idempotent Attr getattr(long tok, string path) throws AuthError, SystemError;
- void symlink(long tok, string path1, string path2) throws AuthError, SystemError;
- void link(long tok, string path1, string path2) throws AuthError, SystemError;
- void rename(long tok, string from, string to) throws AuthError, SystemError;
- idempotent string readlink(long tok, string path) throws AuthError, SystemError;
- idempotent void chmod(long tok, string path, int mode) throws AuthError, SystemError;
- idempotent void chown(long tok, string path, int uid, int gid) throws AuthError, SystemError;
+ idempotent int access(ReqEnv env, string path, int mode) throws AuthError, SystemError;
+ idempotent Attr getattr(ReqEnv env, string path) throws AuthError, SystemError;
+ void symlink(ReqEnv env, string path1, string path2) throws AuthError, SystemError;
+ void link(ReqEnv env, string path1, string path2) throws AuthError, SystemError;
+ void rename(ReqEnv env, string from, string to) throws AuthError, SystemError;
+ idempotent string readlink(ReqEnv env, string path) throws AuthError, SystemError;
+ idempotent void chmod(ReqEnv env, string path, int mode) throws AuthError, SystemError;
+ idempotent void chown(ReqEnv env, string path, int uid, int gid) throws AuthError, SystemError;
};
interface Service {
long connect(string volume, string auth) throws AuthError, ConfigError;