summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/daemon/daemon.cpp4
-rw-r--r--netfs/daemon/daemonVolume.cpp6
-rw-r--r--netfs/daemon/modeCheck.cpp6
-rw-r--r--netfs/daemon/modeCheck.h9
4 files changed, 14 insertions, 11 deletions
diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp
index 20a8562..59f3638 100644
--- a/netfs/daemon/daemon.cpp
+++ b/netfs/daemon/daemon.cpp
@@ -95,7 +95,7 @@ TempPrivs::AssertRead(const boost::filesystem::path & p) const
if (::lstat(p.string().c_str(), &s) != 0) {
throw NetFS::SystemError(errno);
}
- if (!ReadableBy(s, myu, myg)) {
+ if (!ModeCheck::ReadableBy(s, myu, myg)) {
throw NetFS::SystemError(EACCES);
}
}
@@ -110,7 +110,7 @@ TempPrivs::AssertWrite(const boost::filesystem::path & p) const
if (::lstat(p.string().c_str(), &s) != 0) {
throw NetFS::SystemError(errno);
}
- if (!WritableBy(s, myu, myg)) {
+ if (!ModeCheck::WritableBy(s, myu, myg)) {
throw NetFS::SystemError(EACCES);
}
}
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp
index e457098..40082cc 100644
--- a/netfs/daemon/daemonVolume.cpp
+++ b/netfs/daemon/daemonVolume.cpp
@@ -47,13 +47,13 @@ VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::In
return 0;
}
tp.AssertRead(p.parent_path());
- if (mode & R_OK && !ReadableBy(s, tp.myu, tp.myg)) {
+ if (mode & R_OK && !ModeCheck::ReadableBy(s, tp.myu, tp.myg)) {
return EACCES;
}
- if (mode & W_OK && !WritableBy(s, tp.myu, tp.myg)) {
+ if (mode & W_OK && !ModeCheck::WritableBy(s, tp.myu, tp.myg)) {
return EACCES;
}
- if (mode & X_OK && !ExecutableBy(s, tp.myu, tp.myg)) {
+ if (mode & X_OK && !ModeCheck::ExecutableBy(s, tp.myu, tp.myg)) {
return EACCES;
}
return 0;
diff --git a/netfs/daemon/modeCheck.cpp b/netfs/daemon/modeCheck.cpp
index 63ae46a..637abe3 100644
--- a/netfs/daemon/modeCheck.cpp
+++ b/netfs/daemon/modeCheck.cpp
@@ -5,7 +5,7 @@
#define gs GroupEntCache::instance
bool
-ReadableBy(const struct stat & s, uid_t u, gid_t g)
+ModeCheck::ReadableBy(const struct stat & s, uid_t u, gid_t g)
{
if (u == 0) return true;
if (s.st_mode & S_IROTH) return true;
@@ -15,7 +15,7 @@ ReadableBy(const struct stat & s, uid_t u, gid_t g)
}
bool
-WritableBy(const struct stat & s, uid_t u, gid_t g)
+ModeCheck::WritableBy(const struct stat & s, uid_t u, gid_t g)
{
if (u == 0) return true;
if (s.st_mode & S_IWOTH) return true;
@@ -25,7 +25,7 @@ WritableBy(const struct stat & s, uid_t u, gid_t g)
}
bool
-ExecutableBy(const struct stat & s, uid_t u, gid_t g)
+ModeCheck::ExecutableBy(const struct stat & s, uid_t u, gid_t g)
{
if (u == 0 && (s.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR))) return true;
if (s.st_mode & S_IXOTH) return true;
diff --git a/netfs/daemon/modeCheck.h b/netfs/daemon/modeCheck.h
index ed2d60b..b3377bd 100644
--- a/netfs/daemon/modeCheck.h
+++ b/netfs/daemon/modeCheck.h
@@ -3,9 +3,12 @@
#include <sys/stat.h>
-bool ReadableBy(const struct stat &, uid_t u, gid_t g);
-bool WritableBy(const struct stat &, uid_t u, gid_t g);
-bool ExecutableBy(const struct stat &, uid_t u, gid_t g);
+class ModeCheck {
+ public:
+ static bool ReadableBy(const struct stat &, uid_t u, gid_t g);
+ static bool WritableBy(const struct stat &, uid_t u, gid_t g);
+ static bool ExecutableBy(const struct stat &, uid_t u, gid_t g);
+};
#endif