summaryrefslogtreecommitdiff
path: root/netfs/daemon
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-04-01 19:08:09 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-04-01 19:08:09 +0100
commit46f6aa3507120f4b69a54abc02d8829eac005b6f (patch)
treeeee0591714bfa56c5e3036c30cf57b7a55e288f5 /netfs/daemon
parentFirst round of clang tidy changes (diff)
downloadnetfs-46f6aa3507120f4b69a54abc02d8829eac005b6f.tar.bz2
netfs-46f6aa3507120f4b69a54abc02d8829eac005b6f.tar.xz
netfs-46f6aa3507120f4b69a54abc02d8829eac005b6f.zip
Enable hicpp tidy checks
Diffstat (limited to 'netfs/daemon')
-rw-r--r--netfs/daemon/daemonDirectory.cpp3
-rw-r--r--netfs/daemon/daemonFile.cpp2
-rw-r--r--netfs/daemon/daemonVolume.cpp44
-rw-r--r--netfs/daemon/daemonVolume.h36
-rw-r--r--netfs/daemon/modeCheck.cpp62
5 files changed, 91 insertions, 56 deletions
diff --git a/netfs/daemon/daemonDirectory.cpp b/netfs/daemon/daemonDirectory.cpp
index 44aa765..5e5c8ad 100644
--- a/netfs/daemon/daemonDirectory.cpp
+++ b/netfs/daemon/daemonDirectory.cpp
@@ -53,7 +53,8 @@ DirectoryServer::listdir(const Ice::Current&)
throw NetFS::SystemError(errno);
// LCOV_EXCL_STOP
}
- struct stat s;
+ struct stat s {};
+ // NOLINTNEXTLINE(hicpp-no-array-decay)
if (::fstatat(fd, d->d_name, &s, AT_SYMLINK_NOFOLLOW) != 0) {
// LCOV_EXCL_START
throw NetFS::SystemError(errno);
diff --git a/netfs/daemon/daemonFile.cpp b/netfs/daemon/daemonFile.cpp
index 1113904..48730bc 100644
--- a/netfs/daemon/daemonFile.cpp
+++ b/netfs/daemon/daemonFile.cpp
@@ -27,7 +27,7 @@ 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);
}
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp
index fd2f895..074580c 100644
--- a/netfs/daemon/daemonVolume.cpp
+++ b/netfs/daemon/daemonVolume.cpp
@@ -30,10 +30,10 @@ VolumeServer::disconnect(const Ice::Current & ice)
}
Ice::Int
-VolumeServer::access(const NetFS::ReqEnv re, const std::string path, Ice::Int mode, const Ice::Current &)
+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;
@@ -56,10 +56,10 @@ VolumeServer::access(const NetFS::ReqEnv re, const std::string path, Ice::Int mo
}
NetFS::Attr
-VolumeServer::getattr(const NetFS::ReqEnv re, const std::string path, const Ice::Current &)
+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 +69,7 @@ VolumeServer::getattr(const NetFS::ReqEnv re, const std::string path, const Ice:
}
void
-VolumeServer::mknod(const NetFS::ReqEnv re, const 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;
@@ -81,7 +81,7 @@ VolumeServer::mknod(const NetFS::ReqEnv re, const std::string path, Ice::Int mod
}
void
-VolumeServer::symlink(const NetFS::ReqEnv re, const std::string path1, const std::string path2, const Ice::Current &)
+VolumeServer::symlink(const NetFS::ReqEnv re, const std::string path1, std::string path2, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -97,7 +97,7 @@ VolumeServer::symlink(const NetFS::ReqEnv re, const std::string path1, const std
}
void
-VolumeServer::link(const NetFS::ReqEnv re, const std::string path1, const std::string path2, const Ice::Current &)
+VolumeServer::link(const NetFS::ReqEnv re, std::string path1, std::string path2, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -113,7 +113,7 @@ VolumeServer::link(const NetFS::ReqEnv re, const std::string path1, const std::s
}
void
-VolumeServer::rename(const NetFS::ReqEnv re, const std::string from, const std::string to, const Ice::Current &)
+VolumeServer::rename(const NetFS::ReqEnv re, std::string from, std::string to, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -127,7 +127,7 @@ VolumeServer::rename(const NetFS::ReqEnv re, const std::string from, const std::
}
std::string
-VolumeServer::readlink(const NetFS::ReqEnv re, const std::string path, const Ice::Current &)
+VolumeServer::readlink(const NetFS::ReqEnv re, std::string path, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -143,7 +143,7 @@ VolumeServer::readlink(const NetFS::ReqEnv re, const std::string path, const Ice
}
void
-VolumeServer::chmod(const NetFS::ReqEnv re, const std::string path, Ice::Int mode, const Ice::Current &)
+VolumeServer::chmod(const NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -155,7 +155,7 @@ VolumeServer::chmod(const NetFS::ReqEnv re, const std::string path, Ice::Int mod
}
void
-VolumeServer::chown(const NetFS::ReqEnv re, const std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current &)
+VolumeServer::chown(const NetFS::ReqEnv re, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current &)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -167,7 +167,7 @@ VolumeServer::chown(const NetFS::ReqEnv re, const std::string path, Ice::Int uid
}
void
-VolumeServer::utimens(const NetFS::ReqEnv re, const std::string path,
+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);
@@ -181,11 +181,11 @@ VolumeServer::utimens(const NetFS::ReqEnv re, const std::string path,
}
NetFS::VFS
-VolumeServer::statfs(const NetFS::ReqEnv re, const 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) {
@@ -195,7 +195,7 @@ VolumeServer::statfs(const NetFS::ReqEnv re, const std::string path, const Ice::
}
void
-VolumeServer::truncate(const NetFS::ReqEnv re, const 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;
@@ -207,7 +207,7 @@ VolumeServer::truncate(const NetFS::ReqEnv re, const std::string path, Ice::Long
}
void
-VolumeServer::unlink(const NetFS::ReqEnv re, const 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;
@@ -219,7 +219,7 @@ VolumeServer::unlink(const NetFS::ReqEnv re, const std::string path, const Ice::
}
NetFS::FilePrxPtr
-VolumeServer::open(const NetFS::ReqEnv re, const std::string path, Ice::Int flags, const Ice::Current & ice)
+VolumeServer::open(const NetFS::ReqEnv re, std::string path, Ice::Int flags, const Ice::Current & ice)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -237,7 +237,7 @@ VolumeServer::open(const NetFS::ReqEnv re, const std::string path, Ice::Int flag
}
NetFS::FilePrxPtr
-VolumeServer::create(const NetFS::ReqEnv re, const std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current & ice)
+VolumeServer::create(const NetFS::ReqEnv re, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current & ice)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -257,7 +257,7 @@ VolumeServer::create(const NetFS::ReqEnv re, const std::string path, Ice::Int fl
}
NetFS::DirectoryPrxPtr
-VolumeServer::opendir(const NetFS::ReqEnv re, const std::string path, const Ice::Current & ice)
+VolumeServer::opendir(const NetFS::ReqEnv re, std::string path, const Ice::Current & ice)
{
ModeCheck mc(re, root, userLookup, groupLookup);
errno = 0;
@@ -272,7 +272,7 @@ VolumeServer::opendir(const NetFS::ReqEnv re, const std::string path, const Ice:
}
void
-VolumeServer::mkdir(const NetFS::ReqEnv re, const 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;
@@ -288,7 +288,7 @@ VolumeServer::mkdir(const NetFS::ReqEnv re, const std::string path, Ice::Int mod
}
void
-VolumeServer::rmdir(const NetFS::ReqEnv re, const 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;
@@ -323,7 +323,7 @@ normalizedAppend(std::filesystem::path out, const std::filesystem::path && in)
}
std::filesystem::path
-VolumeServer::resolvePath(const std::string && path) const
+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 5087654..190f146 100644
--- a/netfs/daemon/daemonVolume.h
+++ b/netfs/daemon/daemonVolume.h
@@ -11,35 +11,35 @@ class VolumeServer : public NetFS::Volume {
public:
VolumeServer(const std::filesystem::path & root, const EntCache<User> &, const EntCache<Group> &);
- virtual NetFS::DirectoryPrxPtr opendir(const NetFS::ReqEnv, const std::string path, const Ice::Current&) override;
+ virtual NetFS::DirectoryPrxPtr opendir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual void mkdir(const NetFS::ReqEnv, const std::string path, Ice::Int id, const Ice::Current&) override;
- virtual void rmdir(const NetFS::ReqEnv, const std::string path, const Ice::Current&) override;
+ virtual void mkdir(const NetFS::ReqEnv, std::string path, Ice::Int id, const Ice::Current&) override;
+ virtual void rmdir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual void truncate(const NetFS::ReqEnv, const std::string path, Ice::Long size, const Ice::Current&) override;
+ virtual void truncate(const NetFS::ReqEnv, std::string path, Ice::Long size, const Ice::Current&) override;
- virtual void unlink(const NetFS::ReqEnv, const std::string path, const Ice::Current&) override;
+ virtual void unlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual NetFS::FilePrxPtr open(const NetFS::ReqEnv, const std::string path, Ice::Int flags, const Ice::Current&) override;
- virtual NetFS::FilePrxPtr create(const NetFS::ReqEnv, const std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override;
+ virtual NetFS::FilePrxPtr open(const NetFS::ReqEnv, std::string path, Ice::Int flags, const Ice::Current&) override;
+ virtual NetFS::FilePrxPtr create(const NetFS::ReqEnv, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override;
- virtual NetFS::VFS statfs(const NetFS::ReqEnv, const std::string path, const Ice::Current&) override;
+ virtual NetFS::VFS statfs(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual Ice::Int access(const NetFS::ReqEnv, const std::string path, Ice::Int mode, const Ice::Current&) override;
- virtual NetFS::Attr getattr(const NetFS::ReqEnv, const std::string path, const Ice::Current&) override;
- virtual void mknod(const NetFS::ReqEnv, const std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override;
+ virtual Ice::Int access(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
+ virtual NetFS::Attr getattr(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ virtual void mknod(const NetFS::ReqEnv, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override;
virtual void symlink(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current&) override;
- virtual void link(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current&) override;
- virtual void rename(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current&) override;
- virtual std::string readlink(const NetFS::ReqEnv, const std::string path, const Ice::Current&) override;
- virtual void chmod(const NetFS::ReqEnv, const std::string path, Ice::Int mode, const Ice::Current&) override;
- virtual void chown(const NetFS::ReqEnv, const std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override;
- virtual void utimens(const NetFS::ReqEnv, const std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override;
+ virtual void link(const NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override;
+ virtual void rename(const NetFS::ReqEnv, std::string path1, const std::string path2, const Ice::Current&) override;
+ virtual std::string readlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ virtual void chmod(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
+ virtual void chown(const NetFS::ReqEnv, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override;
+ virtual void utimens(const NetFS::ReqEnv, std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override;
virtual void disconnect(const Ice::Current&) override;
protected:
- std::filesystem::path resolvePath(const std::string && path) const;
+ std::filesystem::path resolvePath(std::string path) const;
private:
const std::filesystem::path root;
diff --git a/netfs/daemon/modeCheck.cpp b/netfs/daemon/modeCheck.cpp
index 91bbe20..58ade75 100644
--- a/netfs/daemon/modeCheck.cpp
+++ b/netfs/daemon/modeCheck.cpp
@@ -64,10 +64,10 @@ 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);
}
@@ -77,30 +77,64 @@ ModeCheck::lstat(const std::filesystem::path & p)
bool
ModeCheck::ReadableBy(const struct stat & s, uid_t u, gid_t g) const
{
- 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 || userLookup.getEntry(u)->group == s.st_gid || groupLookup.getEntry(s.st_gid)->hasMember(u))) return true;
+ 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
+ || userLookup.getEntry(u)->group == s.st_gid
+ || groupLookup.getEntry(s.st_gid)->hasMember(u)))
+ {
+ return true;
+ }
return false;
}
bool
ModeCheck::WritableBy(const struct stat & s, uid_t u, gid_t g) const
{
- 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 || userLookup.getEntry(u)->group == s.st_gid || groupLookup.getEntry(s.st_gid)->hasMember(u))) return true;
+ 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
+ || userLookup.getEntry(u)->group == s.st_gid
+ || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
+ return true;
+ }
return false;
}
bool
ModeCheck::ExecutableBy(const struct stat & s, uid_t u, gid_t g) const
{
- 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 || userLookup.getEntry(u)->group == s.st_gid || groupLookup.getEntry(s.st_gid)->hasMember(u))) return true;
+ 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
+ || userLookup.getEntry(u)->group == s.st_gid
+ || groupLookup.getEntry(s.st_gid)->hasMember(u))) {
+ return true;
+ }
return false;
}