#ifndef NETFS_DAEMON_IOHELPERS #define NETFS_DAEMON_IOHELPERS #include #include #include #include #include class ModeCheck { public: ModeCheck(const NetFS::ReqEnv & re, const std::filesystem::path &, const EntryResolver &, const EntryResolver &); void AssertReadParent(const std::filesystem::path &) const; void AssertRead(const std::filesystem::path &) const; void AssertWriteParent(const std::filesystem::path &) const; void AssertWrite(const std::filesystem::path &) const; void AssertWritePerms(const std::filesystem::path &) const; const uid_t myu; const gid_t myg; const std::filesystem::path & root; [[nodiscard]] bool ReadableBy(const struct stat &, uid_t u, gid_t g) const; [[nodiscard]] bool WritableBy(const struct stat &, uid_t u, gid_t g) const; [[nodiscard]] bool ExecutableBy(const struct stat &, uid_t u, gid_t g) const; private: static struct stat lstat(const std::filesystem::path &); const EntryResolver & userLookup; const EntryResolver & groupLookup; }; #endif