summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-09-06 00:17:45 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2020-09-06 00:17:45 +0100
commit1cd8302a4ba6e4553738a1547de37af12a6aa35f (patch)
tree7d8af97c33993f72a2e1b697d9c2abc40aa97b9d
parentSupport mapper rejection signalled by 0 st_mode (diff)
downloadnetfs-1cd8302a4ba6e4553738a1547de37af12a6aa35f.tar.bz2
netfs-1cd8302a4ba6e4553738a1547de37af12a6aa35f.tar.xz
netfs-1cd8302a4ba6e4553738a1547de37af12a6aa35f.zip
Add the HideUnknown mapper
This mapper hides inodes for which the user and/or group cannot be mapped to local entries
-rw-r--r--netfs/fuse/Jamfile.jam23
-rw-r--r--netfs/fuse/fuseApp.cpp12
-rw-r--r--netfs/fuse/fuseMappers.ice12
-rw-r--r--netfs/fuse/fuseMappersImpl.cpp36
-rw-r--r--netfs/fuse/fuseMappersImpl.h25
5 files changed, 101 insertions, 7 deletions
diff --git a/netfs/fuse/Jamfile.jam b/netfs/fuse/Jamfile.jam
index d700c37..4d000be 100644
--- a/netfs/fuse/Jamfile.jam
+++ b/netfs/fuse/Jamfile.jam
@@ -3,20 +3,29 @@ import package ;
lib Glacier2 : : <name>Glacier2++11 ;
constant FUSE_VER : 35 ;
-obj fuseConfig : fuseConfig.ice :
- <toolset>tidy:<checker>none
- <library>../ice//netfs-api
- <implicit-dependency>../ice//netfs-api
- <library>..//slicer
- <include>.
-;
+rule iceobj ( name : ice ) {
+ obj $(name) : $(ice) :
+ <toolset>tidy:<checker>none
+ <library>../ice//netfs-api
+ <implicit-dependency>../ice//netfs-api
+ <library>..//slicer
+ <include>.
+ ;
+}
+iceobj fuseConfig : fuseConfig.ice ;
+iceobj fuseMappers : fuseMappers.ice ;
+
lib netfs-client-configuration :
fuseConfig
+ fuseMappers
fuseConfig.ice
+ fuseMappers.ice
fuseConfigImpl.cpp
+ fuseMappersImpl.cpp
:
<slicer>pure
<library>../ice//netfs-api
+ <library>../lib//netfs-common
<implicit-dependency>../ice//netfs-api
<implicit-dependency>fuseConfig
<library>..//Ice
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp
index f0576b3..ff1585a 100644
--- a/netfs/fuse/fuseApp.cpp
+++ b/netfs/fuse/fuseApp.cpp
@@ -2,6 +2,7 @@
#include "cache.impl.h"
#include "fuseDirs.h"
#include "fuseFiles.h"
+#include "fuseMappersImpl.h"
#include "lockHelpers.h"
#include <Glacier2/Router.h>
#include <boost/lexical_cast.hpp>
@@ -111,7 +112,18 @@ NetFS::FuseApp::configureFromUri(const std::string & uriString)
setting = boost::lexical_cast<std::remove_reference_t<decltype(setting)>>(p->second);
}
};
+ auto setWith = [&uri](const auto & param, auto & setting, auto && f) {
+ if (auto p = uri.query.find(param); p != uri.query.end()) {
+ setting = f(p->second);
+ }
+ };
set("async", r->Async);
+ setWith("mapper", r->mapper, [](auto && m) -> NetFS::Mapping::MapperPtr {
+ if (m == "hide") {
+ return std::make_shared<NetFS::Client::HideUnknownMapperImpl>();
+ }
+ return {};
+ });
return r;
}
diff --git a/netfs/fuse/fuseMappers.ice b/netfs/fuse/fuseMappers.ice
new file mode 100644
index 0000000..6945eec
--- /dev/null
+++ b/netfs/fuse/fuseMappers.ice
@@ -0,0 +1,12 @@
+#include <mapper.ice>
+
+["slicer:include:fuseMappersImpl.h"]
+module NetFS {
+ module Client {
+ ["slicer:implementation:NetFS.Client.HideUnknownMapperImpl"]
+ local class HideUnknownMapper extends Mapping::Mapper {
+
+ };
+ };
+};
+
diff --git a/netfs/fuse/fuseMappersImpl.cpp b/netfs/fuse/fuseMappersImpl.cpp
new file mode 100644
index 0000000..9a99eca
--- /dev/null
+++ b/netfs/fuse/fuseMappersImpl.cpp
@@ -0,0 +1,36 @@
+#include "fuseMappersImpl.h"
+#include <entCache.h>
+
+namespace NetFS::Client {
+ HideUnknownMapperImpl::HideUnknownMapperImpl() :
+ HideUnknownMapperImpl(std::make_shared<EntCache<User>>(), std::make_shared<EntCache<Group>>())
+ {
+ }
+
+ HideUnknownMapperImpl::HideUnknownMapperImpl(EntryResolverPtr<User> u, EntryResolverPtr<Group> g) :
+ users(std::move(u)), groups(std::move(g))
+ {
+ }
+
+ Mapping::FileSystem
+ HideUnknownMapperImpl::mapTransport(const std::string & un, const std::string & gn)
+ {
+ auto u = users->getEntry(un);
+ auto g = groups->getEntry(gn);
+ if (!u || !g) {
+ return {0, 0, 0xFFFFFFF};
+ }
+ return {static_cast<int>(u->id), static_cast<int>(g->id), 0};
+ }
+
+ Mapping::Transport
+ HideUnknownMapperImpl::mapFileSystem(int uid, int gid)
+ {
+ auto u = users->getEntry(uid);
+ auto g = groups->getEntry(gid);
+ if (!u || !g) {
+ throw NetFS::SystemError(EPERM);
+ }
+ return {u->name, g->name, 0};
+ }
+}
diff --git a/netfs/fuse/fuseMappersImpl.h b/netfs/fuse/fuseMappersImpl.h
new file mode 100644
index 0000000..4b0677f
--- /dev/null
+++ b/netfs/fuse/fuseMappersImpl.h
@@ -0,0 +1,25 @@
+#ifndef NETFS_MAPPING_CLIENTIMPL_H
+#define NETFS_MAPPING_CLIENTIMPL_H
+
+#include "entries.h"
+#include "entryResolver.h"
+#include <fuseMappers.h>
+
+namespace NetFS {
+ namespace Client {
+ class HideUnknownMapperImpl : public HideUnknownMapper {
+ public:
+ HideUnknownMapperImpl();
+ HideUnknownMapperImpl(EntryResolverPtr<User> u, EntryResolverPtr<Group> g);
+
+ Mapping::Transport mapFileSystem(int uid, int gid) override;
+ Mapping::FileSystem mapTransport(const std::string & un, const std::string & gn) override;
+
+ protected:
+ EntryResolverPtr<User> users;
+ EntryResolverPtr<Group> groups;
+ };
+ }
+}
+
+#endif