From 60779db7cf26e256d39593a715ab0712a3009814 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 19 Jul 2015 20:06:42 +0100 Subject: Rename ioHelpers to modeCheck --- netfs/daemon/daemon.cpp | 2 +- netfs/daemon/daemonVolume.cpp | 2 +- netfs/daemon/ioHelpers.cpp | 37 ------------------------------------- netfs/daemon/ioHelpers.h | 11 ----------- netfs/daemon/modeCheck.cpp | 37 +++++++++++++++++++++++++++++++++++++ netfs/daemon/modeCheck.h | 11 +++++++++++ 6 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 netfs/daemon/ioHelpers.cpp delete mode 100644 netfs/daemon/ioHelpers.h create mode 100644 netfs/daemon/modeCheck.cpp create mode 100644 netfs/daemon/modeCheck.h diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp index 9296b72..20a8562 100644 --- a/netfs/daemon/daemon.cpp +++ b/netfs/daemon/daemon.cpp @@ -5,7 +5,7 @@ #include "daemonVolume.h" #include #include -#include "ioHelpers.h" +#include "modeCheck.h" #include NetFSDaemon::NetFSDaemon() diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index afc0d36..e457098 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -11,7 +11,7 @@ #include "daemonFile.h" #include "daemonDirectory.h" #include "lockHelpers.h" -#include "ioHelpers.h" +#include "modeCheck.h" #include #include #include "daemon.h" diff --git a/netfs/daemon/ioHelpers.cpp b/netfs/daemon/ioHelpers.cpp deleted file mode 100644 index 05f809c..0000000 --- a/netfs/daemon/ioHelpers.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "ioHelpers.h" -#include - -#define us UserEntCache::instance -#define gs GroupEntCache::instance - -bool -ReadableBy(const struct stat & s, uid_t u, gid_t g) -{ - if (u == 0) return true; - if (s.st_mode & S_IROTH) return true; - if (s.st_mode & S_IRUSR && s.st_uid == u) return true; - if (s.st_mode & S_IRGRP && (s.st_gid == g || us.getEntry(u)->group == s.st_gid || gs.getEntry(s.st_gid)->hasMember(u))) return true; - return false; -} - -bool -WritableBy(const struct stat & s, uid_t u, gid_t g) -{ - if (u == 0) return true; - if (s.st_mode & S_IWOTH) return true; - if (s.st_mode & S_IWUSR && s.st_uid == u) return true; - if (s.st_mode & S_IWGRP && (s.st_gid == g || us.getEntry(u)->group == s.st_gid || gs.getEntry(s.st_gid)->hasMember(u))) return true; - return false; -} - -bool -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; - if (s.st_mode & S_IXUSR && s.st_uid == u) return true; - if (s.st_mode & S_IXGRP && (s.st_gid == g || us.getEntry(u)->group == s.st_gid || gs.getEntry(s.st_gid)->hasMember(u))) return true; - return false; -} - - diff --git a/netfs/daemon/ioHelpers.h b/netfs/daemon/ioHelpers.h deleted file mode 100644 index ed2d60b..0000000 --- a/netfs/daemon/ioHelpers.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NETFS_DAEMON_IOHELPERS -#define NETFS_DAEMON_IOHELPERS - -#include - -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); - -#endif - diff --git a/netfs/daemon/modeCheck.cpp b/netfs/daemon/modeCheck.cpp new file mode 100644 index 0000000..63ae46a --- /dev/null +++ b/netfs/daemon/modeCheck.cpp @@ -0,0 +1,37 @@ +#include "modeCheck.h" +#include + +#define us UserEntCache::instance +#define gs GroupEntCache::instance + +bool +ReadableBy(const struct stat & s, uid_t u, gid_t g) +{ + if (u == 0) return true; + if (s.st_mode & S_IROTH) return true; + if (s.st_mode & S_IRUSR && s.st_uid == u) return true; + if (s.st_mode & S_IRGRP && (s.st_gid == g || us.getEntry(u)->group == s.st_gid || gs.getEntry(s.st_gid)->hasMember(u))) return true; + return false; +} + +bool +WritableBy(const struct stat & s, uid_t u, gid_t g) +{ + if (u == 0) return true; + if (s.st_mode & S_IWOTH) return true; + if (s.st_mode & S_IWUSR && s.st_uid == u) return true; + if (s.st_mode & S_IWGRP && (s.st_gid == g || us.getEntry(u)->group == s.st_gid || gs.getEntry(s.st_gid)->hasMember(u))) return true; + return false; +} + +bool +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; + if (s.st_mode & S_IXUSR && s.st_uid == u) return true; + if (s.st_mode & S_IXGRP && (s.st_gid == g || us.getEntry(u)->group == s.st_gid || gs.getEntry(s.st_gid)->hasMember(u))) return true; + return false; +} + + diff --git a/netfs/daemon/modeCheck.h b/netfs/daemon/modeCheck.h new file mode 100644 index 0000000..ed2d60b --- /dev/null +++ b/netfs/daemon/modeCheck.h @@ -0,0 +1,11 @@ +#ifndef NETFS_DAEMON_IOHELPERS +#define NETFS_DAEMON_IOHELPERS + +#include + +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); + +#endif + -- cgit v1.2.3