summaryrefslogtreecommitdiff
path: root/netfs/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'netfs/daemon')
-rw-r--r--netfs/daemon/daemon.cpp23
-rw-r--r--netfs/daemon/daemon.h31
-rw-r--r--netfs/daemon/daemonConfigImpl.cpp3
-rw-r--r--netfs/daemon/daemonDirectory.cpp20
-rw-r--r--netfs/daemon/daemonDirectory.h17
-rw-r--r--netfs/daemon/daemonFile.cpp33
-rw-r--r--netfs/daemon/daemonFile.h22
-rw-r--r--netfs/daemon/daemonService.cpp10
-rw-r--r--netfs/daemon/daemonService.h18
-rw-r--r--netfs/daemon/daemonVolume.cpp68
-rw-r--r--netfs/daemon/daemonVolume.h66
-rw-r--r--netfs/daemon/modeCheck.cpp36
-rw-r--r--netfs/daemon/modeCheck.h39
13 files changed, 179 insertions, 207 deletions
diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp
index ddd67f2..e232aaa 100644
--- a/netfs/daemon/daemon.cpp
+++ b/netfs/daemon/daemon.cpp
@@ -1,11 +1,11 @@
-#include <Ice/Ice.h>
#include "daemon.h"
#include "daemonService.h"
#include "daemonVolume.h"
-#include <slicer/slicer.h>
#include "modeCheck.h"
-#include <sys/stat.h>
+#include <Ice/Ice.h>
#include <safeMapFind.h>
+#include <slicer/slicer.h>
+#include <sys/stat.h>
NetFSDaemon::~NetFSDaemon()
{
@@ -32,7 +32,7 @@ NetFSDaemon::hostname()
// name = NetFSDaemonAdapter
void
-NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq&)
+NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &)
{
this->ic = ic;
Ice::PropertiesPtr props = ic->getProperties();
@@ -66,12 +66,11 @@ NetFSDaemon::stop()
}
extern "C" {
- DLL_PUBLIC
- IceBox::Service *
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
- createNetFSDaemon(Ice::CommunicatorPtr)
- {
- return new NetFSDaemon();
- }
+DLL_PUBLIC
+IceBox::Service *
+ // NOLINTNEXTLINE(performance-unnecessary-value-param)
+ createNetFSDaemon(Ice::CommunicatorPtr)
+{
+ return new NetFSDaemon();
+}
}
-
diff --git a/netfs/daemon/daemon.h b/netfs/daemon/daemon.h
index cea9643..373c0cb 100644
--- a/netfs/daemon/daemon.h
+++ b/netfs/daemon/daemon.h
@@ -3,32 +3,31 @@
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
+#include <c++11Helpers.h>
#include <daemonConfig.h>
#include <filesystem>
#include <visibility.h>
-#include <c++11Helpers.h>
class DLL_PUBLIC NetFSDaemon : public IceBox::Service {
- public:
- NetFSDaemon() = default;
- SPECIAL_MEMBERS_MOVE_RO(NetFSDaemon);
- ~NetFSDaemon() override;
+public:
+ NetFSDaemon() = default;
+ SPECIAL_MEMBERS_MOVE_RO(NetFSDaemon);
+ ~NetFSDaemon() override;
- void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&) override;
- void stop() override;
+ void start(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &) override;
+ void stop() override;
- protected:
- [[nodiscard]] virtual NetFS::Daemon::ConfigurationPtr ReadConfiguration(const std::filesystem::path & path) const;
+protected:
+ [[nodiscard]] virtual NetFS::Daemon::ConfigurationPtr ReadConfiguration(const std::filesystem::path & path) const;
- private:
- void LoadConfiguration(const std::filesystem::path & path);
+private:
+ void LoadConfiguration(const std::filesystem::path & path);
- Ice::CommunicatorPtr ic;
- Ice::ObjectAdapterPtr adapter;
- NetFS::Daemon::RuntimeConfigurationPtr dc;
+ Ice::CommunicatorPtr ic;
+ Ice::ObjectAdapterPtr adapter;
+ NetFS::Daemon::RuntimeConfigurationPtr dc;
- std::string hostname();
+ std::string hostname();
};
#endif
-
diff --git a/netfs/daemon/daemonConfigImpl.cpp b/netfs/daemon/daemonConfigImpl.cpp
index 48b1d0e..e45cf97 100644
--- a/netfs/daemon/daemonConfigImpl.cpp
+++ b/netfs/daemon/daemonConfigImpl.cpp
@@ -1,5 +1,5 @@
-#include <daemonConfig.h>
#include <compileTimeFormatter.h>
+#include <daemonConfig.h>
AdHocFormatter(HostNotConfiguredMsg, "This host [%?] is not defined in the configuration");
void
@@ -7,4 +7,3 @@ NetFS::Daemon::HostNotConfigured::ice_print(std::ostream & s) const
{
HostNotConfiguredMsg::write(s, hostName);
}
-
diff --git a/netfs/daemon/daemonDirectory.cpp b/netfs/daemon/daemonDirectory.cpp
index 22c0e4f..cf56c72 100644
--- a/netfs/daemon/daemonDirectory.cpp
+++ b/netfs/daemon/daemonDirectory.cpp
@@ -1,17 +1,13 @@
+#include "daemonDirectory.h"
#include <Ice/ObjectAdapter.h>
-#include <dirent.h>
#include <cerrno>
+#include <dirent.h>
+#include <fcntl.h>
#include <map>
#include <sys/stat.h>
#include <sys/types.h>
-#include <fcntl.h>
-#include "daemonDirectory.h"
-DirectoryServer::DirectoryServer(DIR * d, EntryTypeConverter & t) :
- EntryTypeConverter(t),
- od(d)
-{
-}
+DirectoryServer::DirectoryServer(DIR * d, EntryTypeConverter & t) : EntryTypeConverter(t), od(d) { }
void
DirectoryServer::close(const Ice::Current & ice)
@@ -26,7 +22,7 @@ DirectoryServer::close(const Ice::Current & ice)
}
NetFS::NameList
-DirectoryServer::readdir(const Ice::Current&)
+DirectoryServer::readdir(const Ice::Current &)
{
errno = 0;
NetFS::NameList list;
@@ -42,7 +38,7 @@ DirectoryServer::readdir(const Ice::Current&)
}
NetFS::DirectoryContents
-DirectoryServer::listdir(const Ice::Current&)
+DirectoryServer::listdir(const Ice::Current &)
{
errno = 0;
NetFS::DirectoryContents list;
@@ -53,7 +49,8 @@ DirectoryServer::listdir(const Ice::Current&)
throw NetFS::SystemError(errno);
// LCOV_EXCL_STOP
}
- struct stat s {};
+ struct stat s {
+ };
if (::fstatat(fd, d->d_name, &s, AT_SYMLINK_NOFOLLOW) != 0) {
// LCOV_EXCL_START
throw NetFS::SystemError(errno);
@@ -63,4 +60,3 @@ DirectoryServer::listdir(const Ice::Current&)
}
return list;
}
-
diff --git a/netfs/daemon/daemonDirectory.h b/netfs/daemon/daemonDirectory.h
index e74f5dc..83a827a 100644
--- a/netfs/daemon/daemonDirectory.h
+++ b/netfs/daemon/daemonDirectory.h
@@ -6,18 +6,15 @@
#include <typeConverter.h>
class DirectoryServer : public NetFS::Directory, EntryTypeConverter {
- public:
- DirectoryServer(DIR * od, EntryTypeConverter &);
+public:
+ DirectoryServer(DIR * od, EntryTypeConverter &);
- void close(const Ice::Current&) override;
- NetFS::NameList readdir(const Ice::Current&) override;
- NetFS::DirectoryContents listdir(const Ice::Current&) override;
+ void close(const Ice::Current &) override;
+ NetFS::NameList readdir(const Ice::Current &) override;
+ NetFS::DirectoryContents listdir(const Ice::Current &) override;
- private:
- DIR * od;
+private:
+ DIR * od;
};
#endif
-
-
-
diff --git a/netfs/daemon/daemonFile.cpp b/netfs/daemon/daemonFile.cpp
index ec96bc3..56adcc5 100644
--- a/netfs/daemon/daemonFile.cpp
+++ b/netfs/daemon/daemonFile.cpp
@@ -1,21 +1,17 @@
+#include "daemonFile.h"
#include <Ice/ObjectAdapter.h>
#include <cerrno>
-#include <map>
+#include <entCache.h>
#include <fcntl.h>
-#include <typeConverter.h>
+#include <map>
#include <sys/stat.h>
-#include "daemonFile.h"
-#include <entCache.h>
+#include <typeConverter.h>
#include <unistd.h>
-FileServer::FileServer(int f, EntryTypeConverter & t) :
- EntryTypeConverter(t),
- fd(f)
-{
-}
+FileServer::FileServer(int f, EntryTypeConverter & t) : EntryTypeConverter(t), fd(f) { }
void
-FileServer::ftruncate(const NetFS::ReqEnv re, Ice::Long size, const Ice::Current&)
+FileServer::ftruncate(const NetFS::ReqEnv re, Ice::Long size, const Ice::Current &)
{
(void)re;
errno = 0;
@@ -28,7 +24,8 @@ NetFS::Attr
FileServer::fgetattr(const NetFS::ReqEnv re, const Ice::Current &)
{
(void)re;
- struct stat s {};
+ struct stat s {
+ };
if (::fstat(fd, &s) != 0) {
throw NetFS::SystemError(errno);
}
@@ -46,7 +43,7 @@ FileServer::close(const Ice::Current & ice)
}
NetFS::Buffer
-FileServer::read(Ice::Long offset, Ice::Long size, const Ice::Current&)
+FileServer::read(Ice::Long offset, Ice::Long size, const Ice::Current &)
{
NetFS::Buffer buf;
buf.resize(size);
@@ -62,7 +59,7 @@ FileServer::read(Ice::Long offset, Ice::Long size, const Ice::Current&)
}
void
-FileServer::write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, const Ice::Current&)
+FileServer::write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, const Ice::Current &)
{
errno = 0;
if (pwrite(fd, &data.front(), size, offset) != size) {
@@ -71,14 +68,13 @@ FileServer::write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, co
}
Ice::Long
-FileServer::copyrange(NetFS::FilePrxPtr to, Ice::Long offsrc, Ice::Long offdst, Ice::Long size, Ice::Int flags, const Ice::Current& ice)
+FileServer::copyrange(NetFS::FilePrxPtr to, Ice::Long offsrc, Ice::Long offdst, Ice::Long size, Ice::Int flags,
+ const Ice::Current & ice)
{
- if (auto obj = ice.adapter->findByProxy(to);
- auto file = std::dynamic_pointer_cast<FileServer>(obj)) {
+ if (auto obj = ice.adapter->findByProxy(to); auto file = std::dynamic_pointer_cast<FileServer>(obj)) {
errno = 0;
off_t src = offsrc, dst = offdst;
- if (auto rtn = copy_file_range(fd, &src, file->fd, &dst, size, flags);
- rtn != -1) {
+ if (auto rtn = copy_file_range(fd, &src, file->fd, &dst, size, flags); rtn != -1) {
return rtn;
}
throw NetFS::SystemError(errno);
@@ -88,4 +84,3 @@ FileServer::copyrange(NetFS::FilePrxPtr to, Ice::Long offsrc, Ice::Long offdst,
return size;
}
}
-
diff --git a/netfs/daemon/daemonFile.h b/netfs/daemon/daemonFile.h
index 7c4c121..e5b7475 100644
--- a/netfs/daemon/daemonFile.h
+++ b/netfs/daemon/daemonFile.h
@@ -5,21 +5,19 @@
#include <typeConverter.h>
class FileServer : public NetFS::File, EntryTypeConverter {
- public:
- FileServer(int fd, EntryTypeConverter &);
+public:
+ FileServer(int fd, EntryTypeConverter &);
- void close(const Ice::Current&) override;
- void ftruncate(const NetFS::ReqEnv, Ice::Long size, const Ice::Current&) override;
- NetFS::Attr fgetattr(const NetFS::ReqEnv, const Ice::Current&) override;
+ void close(const Ice::Current &) override;
+ void ftruncate(const NetFS::ReqEnv, Ice::Long size, const Ice::Current &) override;
+ NetFS::Attr fgetattr(const NetFS::ReqEnv, const Ice::Current &) override;
- NetFS::Buffer read(Ice::Long offset, Ice::Long size, const Ice::Current&) override;
- void write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, const Ice::Current&) override;
- Ice::Long copyrange(NetFS::FilePrxPtr, Ice::Long, Ice::Long, Ice::Long, Ice::Int, const Ice::Current&) override;
+ NetFS::Buffer read(Ice::Long offset, Ice::Long size, const Ice::Current &) override;
+ void write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, const Ice::Current &) override;
+ Ice::Long copyrange(NetFS::FilePrxPtr, Ice::Long, Ice::Long, Ice::Long, Ice::Int, const Ice::Current &) override;
- private:
- const int fd;
+private:
+ const int fd;
};
#endif
-
-
diff --git a/netfs/daemon/daemonService.cpp b/netfs/daemon/daemonService.cpp
index fd5a0fd..18b050d 100644
--- a/netfs/daemon/daemonService.cpp
+++ b/netfs/daemon/daemonService.cpp
@@ -1,12 +1,9 @@
-#include "daemon.h"
#include "daemonService.h"
+#include "daemon.h"
#include "daemonVolume.h"
#include <safeMapFind.h>
-ServiceServer::ServiceServer(NetFS::Daemon::ConfigurationPtr c) :
- config(std::move(c))
-{
-}
+ServiceServer::ServiceServer(NetFS::Daemon::ConfigurationPtr c) : config(std::move(c)) { }
NetFS::VolumePrxPtr
ServiceServer::connect(const std::string share, const std::string authtoken, const Ice::Current & ice)
@@ -16,6 +13,5 @@ ServiceServer::connect(const std::string share, const std::string authtoken, con
throw NetFS::AuthError();
}
return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addFacetWithUUID(
- std::make_shared<VolumeServer>(ex->RootPath, userLookup, groupLookup), "v01"));
+ std::make_shared<VolumeServer>(ex->RootPath, userLookup, groupLookup), "v01"));
}
-
diff --git a/netfs/daemon/daemonService.h b/netfs/daemon/daemonService.h
index 64ae45c..e0f80ef 100644
--- a/netfs/daemon/daemonService.h
+++ b/netfs/daemon/daemonService.h
@@ -1,23 +1,21 @@
#ifndef DAEMONSERVICE_H
#define DAEMONSERVICE_H
-#include <service.h>
-#include <entCache.h>
#include <daemonConfig.h>
#include <entCache.h>
+#include <service.h>
class ServiceServer : public NetFS::Service {
- public:
- explicit ServiceServer(NetFS::Daemon::ConfigurationPtr c);
+public:
+ explicit ServiceServer(NetFS::Daemon::ConfigurationPtr c);
- NetFS::VolumePrxPtr connect(const std::string share, const std::string auth, const Ice::Current&) override;
+ NetFS::VolumePrxPtr connect(const std::string share, const std::string auth, const Ice::Current &) override;
- private:
- EntCache<User> userLookup;
- EntCache<Group> groupLookup;
+private:
+ EntCache<User> userLookup;
+ EntCache<Group> groupLookup;
- NetFS::Daemon::ConfigurationPtr config;
+ NetFS::Daemon::ConfigurationPtr config;
};
#endif
-
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp
index 096d748..3ae43da 100644
--- a/netfs/daemon/daemonVolume.cpp
+++ b/netfs/daemon/daemonVolume.cpp
@@ -1,25 +1,22 @@
-#include <Ice/ObjectAdapter.h>
-#include <cerrno>
-#include <map>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <climits>
-#include <fcntl.h>
#include "daemonVolume.h"
-#include "daemonFile.h"
+#include "daemon.h"
#include "daemonDirectory.h"
+#include "daemonFile.h"
#include "modeCheck.h"
+#include <Ice/ObjectAdapter.h>
#include <boost/algorithm/string/predicate.hpp>
+#include <cerrno>
+#include <climits>
#include <entCache.h>
-#include "daemon.h"
+#include <fcntl.h>
+#include <map>
+#include <sys/stat.h>
+#include <unistd.h>
extern std::map<Ice::Int, int> files;
VolumeServer::VolumeServer(const std::filesystem::path & r, const EntCache<User> & u, const EntCache<Group> & g) :
- root(std::filesystem::canonical(r)),
- userLookup(u),
- groupLookup(g),
- converter(u, g)
+ root(std::filesystem::canonical(r)), userLookup(u), groupLookup(g), converter(u, g)
{
}
@@ -33,7 +30,8 @@ Ice::Int
VolumeServer::access(const NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
- struct stat s {};
+ struct stat s {
+ };
std::filesystem::path p(resolvePath(std::move(path)));
if (::stat(p.c_str(), &s) != 0) {
return errno;
@@ -59,7 +57,8 @@ NetFS::Attr
VolumeServer::getattr(const NetFS::ReqEnv re, std::string path, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
- struct stat s {};
+ struct stat s {
+ };
std::filesystem::path p(resolvePath(std::move(path)));
mc.AssertReadParent(p);
if (::lstat(p.c_str(), &s) != 0) {
@@ -69,7 +68,7 @@ VolumeServer::getattr(const NetFS::ReqEnv re, std::string path, const Ice::Curre
}
void
-VolumeServer::mknod(const NetFS::ReqEnv re, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&)
+VolumeServer::mknod(const NetFS::ReqEnv re, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -113,7 +112,8 @@ VolumeServer::link(const NetFS::ReqEnv re, std::string path1, std::string path2,
}
void
-VolumeServer::rename(const NetFS::ReqEnv re, std::string from, std::string to, const Ice::optional<Ice::Int> flags, const Ice::Current &)
+VolumeServer::rename(const NetFS::ReqEnv re, std::string from, std::string to, const Ice::optional<Ice::Int> flags,
+ const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -170,12 +170,12 @@ VolumeServer::chown(const NetFS::ReqEnv re, std::string path, Ice::Int uid, Ice:
}
void
-VolumeServer::utimens(const NetFS::ReqEnv re, std::string path,
- Ice::Long s0, Ice::Long ns0, Ice::Long s1, Ice::Long ns1, const Ice::Current&)
+VolumeServer::utimens(const NetFS::ReqEnv re, std::string path, Ice::Long s0, Ice::Long ns0, Ice::Long s1,
+ Ice::Long ns1, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
- std::array<struct timespec, 2> times { { { s0, ns0 }, { s1, ns1 } } };
+ std::array<struct timespec, 2> times {{{s0, ns0}, {s1, ns1}}};
std::filesystem::path p(resolvePath(std::move(path)));
mc.AssertWrite(p);
if (::utimensat(0, p.c_str(), times.data(), AT_SYMLINK_NOFOLLOW) != 0) {
@@ -184,11 +184,12 @@ VolumeServer::utimens(const NetFS::ReqEnv re, std::string path,
}
NetFS::VFS
-VolumeServer::statfs(const NetFS::ReqEnv re, std::string path, const Ice::Current&)
+VolumeServer::statfs(const NetFS::ReqEnv re, std::string path, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
- struct statvfs s {};
+ struct statvfs s {
+ };
std::filesystem::path p(resolvePath(std::move(path)));
mc.AssertRead(p);
if (::statvfs(p.c_str(), &s) != 0) {
@@ -198,7 +199,7 @@ VolumeServer::statfs(const NetFS::ReqEnv re, std::string path, const Ice::Curren
}
void
-VolumeServer::truncate(const NetFS::ReqEnv re, std::string path, Ice::Long size, const Ice::Current&)
+VolumeServer::truncate(const NetFS::ReqEnv re, std::string path, Ice::Long size, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -210,7 +211,7 @@ VolumeServer::truncate(const NetFS::ReqEnv re, std::string path, Ice::Long size,
}
void
-VolumeServer::unlink(const NetFS::ReqEnv re, std::string path, const Ice::Current&)
+VolumeServer::unlink(const NetFS::ReqEnv re, std::string path, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -235,8 +236,8 @@ VolumeServer::open(const NetFS::ReqEnv re, std::string path, Ice::Int flags, con
if (fd == -1) {
throw NetFS::SystemError(errno);
}
- return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addFacetWithUUID(
- std::make_shared<FileServer>(fd, converter), "v01"));
+ return Ice::uncheckedCast<NetFS::FilePrx>(
+ ice.adapter->addFacetWithUUID(std::make_shared<FileServer>(fd, converter), "v01"));
}
NetFS::FilePrxPtr
@@ -255,8 +256,8 @@ VolumeServer::create(const NetFS::ReqEnv re, std::string path, Ice::Int flags, I
::unlink(p.c_str());
throw NetFS::SystemError(errno);
}
- return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addFacetWithUUID(
- std::make_shared<FileServer>(fd, converter), "v01"));
+ return Ice::uncheckedCast<NetFS::FilePrx>(
+ ice.adapter->addFacetWithUUID(std::make_shared<FileServer>(fd, converter), "v01"));
}
NetFS::DirectoryPrxPtr
@@ -270,12 +271,12 @@ VolumeServer::opendir(const NetFS::ReqEnv re, std::string path, const Ice::Curre
if (!od) {
throw NetFS::SystemError(errno);
}
- return Ice::uncheckedCast<NetFS::DirectoryPrx>(ice.adapter->addWithUUID(
- std::make_shared<DirectoryServer>(od, converter)));
+ return Ice::uncheckedCast<NetFS::DirectoryPrx>(
+ ice.adapter->addWithUUID(std::make_shared<DirectoryServer>(od, converter)));
}
void
-VolumeServer::mkdir(const NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current&)
+VolumeServer::mkdir(const NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -291,7 +292,7 @@ VolumeServer::mkdir(const NetFS::ReqEnv re, std::string path, Ice::Int mode, con
}
void
-VolumeServer::rmdir(const NetFS::ReqEnv re, std::string path, const Ice::Current&)
+VolumeServer::rmdir(const NetFS::ReqEnv re, std::string path, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -306,7 +307,7 @@ std::filesystem::path
normalizedAppend(std::filesystem::path out, const std::filesystem::path && in)
{
unsigned int depth = 0;
- for(const auto & e : in) {
+ for (const auto & e : in) {
if (e.empty() || e == "." || e == "/") {
continue;
}
@@ -330,4 +331,3 @@ VolumeServer::resolvePath(std::string && path) const
{
return normalizedAppend(root, std::move(path));
}
-
diff --git a/netfs/daemon/daemonVolume.h b/netfs/daemon/daemonVolume.h
index 0f91f67..b75c5d6 100644
--- a/netfs/daemon/daemonVolume.h
+++ b/netfs/daemon/daemonVolume.h
@@ -1,53 +1,55 @@
#ifndef DAEMONVOLUME_H
#define DAEMONVOLUME_H
-#include <volume.h>
-#include <shared_mutex>
-#include <filesystem>
#include <entCache.h>
+#include <filesystem>
+#include <shared_mutex>
#include <typeConverter.h>
+#include <volume.h>
class VolumeServer : public NetFS::Volume {
- public:
- VolumeServer(const std::filesystem::path & root, const EntCache<User> &, const EntCache<Group> &);
+public:
+ VolumeServer(const std::filesystem::path & root, const EntCache<User> &, const EntCache<Group> &);
- NetFS::DirectoryPrxPtr opendir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ NetFS::DirectoryPrxPtr opendir(const NetFS::ReqEnv, std::string path, const Ice::Current &) override;
- void mkdir(const NetFS::ReqEnv, std::string path, Ice::Int id, const Ice::Current&) override;
- void rmdir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ void mkdir(const NetFS::ReqEnv, std::string path, Ice::Int id, const Ice::Current &) override;
+ void rmdir(const NetFS::ReqEnv, std::string path, const Ice::Current &) override;
- void truncate(const NetFS::ReqEnv, std::string path, Ice::Long size, const Ice::Current&) override;
+ void truncate(const NetFS::ReqEnv, std::string path, Ice::Long size, const Ice::Current &) override;
- void unlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ void unlink(const NetFS::ReqEnv, std::string path, const Ice::Current &) override;
- NetFS::FilePrxPtr open(const NetFS::ReqEnv, std::string path, Ice::Int flags, const Ice::Current&) override;
- NetFS::FilePrxPtr create(const NetFS::ReqEnv, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override;
+ NetFS::FilePrxPtr open(const NetFS::ReqEnv, std::string path, Ice::Int flags, const Ice::Current &) override;
+ NetFS::FilePrxPtr create(
+ const NetFS::ReqEnv, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current &) override;
- NetFS::VFS statfs(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ NetFS::VFS statfs(const NetFS::ReqEnv, std::string path, const Ice::Current &) override;
- Ice::Int access(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
- NetFS::Attr getattr(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- void mknod(const NetFS::ReqEnv, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override;
- void symlink(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current&) override;
- void link(const NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override;
- void rename(const NetFS::ReqEnv, std::string path1, const std::string path2, const Ice::optional<Ice::Int>, const Ice::Current&) override;
- std::string readlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- void chmod(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
- void chown(const NetFS::ReqEnv, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override;
- void utimens(const NetFS::ReqEnv, std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override;
+ Ice::Int access(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current &) override;
+ NetFS::Attr getattr(const NetFS::ReqEnv, std::string path, const Ice::Current &) override;
+ void mknod(const NetFS::ReqEnv, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current &) override;
+ void symlink(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current &) override;
+ void link(const NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current &) override;
+ void rename(const NetFS::ReqEnv, std::string path1, const std::string path2, const Ice::optional<Ice::Int>,
+ const Ice::Current &) override;
+ std::string readlink(const NetFS::ReqEnv, std::string path, const Ice::Current &) override;
+ void chmod(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current &) override;
+ void chown(const NetFS::ReqEnv, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current &) override;
+ void utimens(const NetFS::ReqEnv, std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long,
+ const Ice::Current &) override;
- void disconnect(const Ice::Current&) override;
+ void disconnect(const Ice::Current &) override;
- protected:
- inline std::filesystem::path resolvePath(std::string && path) const;
+protected:
+ inline std::filesystem::path resolvePath(std::string && path) const;
- private:
- const std::filesystem::path root;
+private:
+ const std::filesystem::path root;
- const EntCache<User> & userLookup;
- const EntCache<Group> & groupLookup;
- EntryTypeConverter converter;
+ const EntCache<User> & userLookup;
+ const EntCache<Group> & groupLookup;
+ EntryTypeConverter converter;
};
#endif
-
diff --git a/netfs/daemon/modeCheck.cpp b/netfs/daemon/modeCheck.cpp
index 58ade75..6e65888 100644
--- a/netfs/daemon/modeCheck.cpp
+++ b/netfs/daemon/modeCheck.cpp
@@ -2,12 +2,10 @@
#include <entCache.h>
#include <exceptions.h>
-ModeCheck::ModeCheck(const NetFS::ReqEnv & re, const std::filesystem::path & r, const EntCache<User> & u, const EntCache<Group> & g) :
+ModeCheck::ModeCheck(const NetFS::ReqEnv & re, const std::filesystem::path & r, const EntCache<User> & u,
+ const EntCache<Group> & g) :
myu(u.getEntry(re.user)->id),
- myg(g.getEntry(re.grp)->id),
- root(r),
- userLookup(u),
- groupLookup(g)
+ myg(g.getEntry(re.grp)->id), root(r), userLookup(u), groupLookup(g)
{
}
@@ -64,10 +62,11 @@ ModeCheck::AssertWritePerms(const std::filesystem::path & p) const
}
}
- struct stat
+struct stat
ModeCheck::lstat(const std::filesystem::path & p)
{
- struct stat s {};
+ struct stat s {
+ };
if (::lstat(p.c_str(), &s) != 0) {
throw NetFS::SystemError(errno);
}
@@ -86,11 +85,9 @@ ModeCheck::ReadableBy(const struct stat & s, uid_t u, gid_t g) const
if (s.st_mode & S_IRUSR && s.st_uid == u) {
return true;
}
- if (s.st_mode & S_IRGRP &&
- (s.st_gid == g
- || userLookup.getEntry(u)->group == s.st_gid
- || groupLookup.getEntry(s.st_gid)->hasMember(u)))
- {
+ if (s.st_mode & S_IRGRP
+ && (s.st_gid == g || userLookup.getEntry(u)->group == s.st_gid
+ || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
return true;
}
return false;
@@ -108,10 +105,9 @@ ModeCheck::WritableBy(const struct stat & s, uid_t u, gid_t g) const
if (s.st_mode & S_IWUSR && s.st_uid == u) {
return true;
}
- if (s.st_mode & S_IWGRP &&
- (s.st_gid == g
- || userLookup.getEntry(u)->group == s.st_gid
- || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
+ if (s.st_mode & S_IWGRP
+ && (s.st_gid == g || userLookup.getEntry(u)->group == s.st_gid
+ || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
return true;
}
return false;
@@ -129,12 +125,10 @@ ModeCheck::ExecutableBy(const struct stat & s, uid_t u, gid_t g) const
if (s.st_mode & S_IXUSR && s.st_uid == u) {
return true;
}
- if (s.st_mode & S_IXGRP &&
- (s.st_gid == g
- || userLookup.getEntry(u)->group == s.st_gid
- || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
+ if (s.st_mode & S_IXGRP
+ && (s.st_gid == g || userLookup.getEntry(u)->group == s.st_gid
+ || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
return true;
}
return false;
}
-
diff --git a/netfs/daemon/modeCheck.h b/netfs/daemon/modeCheck.h
index 01e9ecb..693ad8d 100644
--- a/netfs/daemon/modeCheck.h
+++ b/netfs/daemon/modeCheck.h
@@ -1,35 +1,34 @@
#ifndef NETFS_DAEMON_IOHELPERS
#define NETFS_DAEMON_IOHELPERS
+#include <entCache.h>
+#include <filesystem>
#include <sys/stat.h>
#include <types.h>
-#include <filesystem>
-#include <entCache.h>
class ModeCheck {
- public:
- ModeCheck(const NetFS::ReqEnv & re, const std::filesystem::path &, const EntCache<User> &, const EntCache<Group> &);
+public:
+ ModeCheck(const NetFS::ReqEnv & re, const std::filesystem::path &, const EntCache<User> &, const EntCache<Group> &);
- 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;
+ 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;
+ 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;
+ [[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 &);
+private:
+ static struct stat lstat(const std::filesystem::path &);
- const EntCache<User> & userLookup;
- const EntCache<Group> & groupLookup;
+ const EntCache<User> & userLookup;
+ const EntCache<Group> & groupLookup;
};
#endif
-