blob: d20f7baf82b76467866fbf21ef16693a05d12433 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "defaultMapper.h"
#include "entCache.h"
#include <exceptions.h>
namespace NetFS::Mapping {
DefaultMapper::DefaultMapper() : DefaultMapper(std::make_shared<UserEntCache>()) { }
DefaultMapper::DefaultMapper(EntryResolverPtr<User> u) :
DefaultMapper(std::move(u), std::make_shared<GroupEntCache>(u))
{
}
DefaultMapper::DefaultMapper(EntryResolverPtr<User> u, EntryResolverPtr<Group> g) :
users(std::move(u)), groups(std::move(g))
{
}
FileSystem
DefaultMapper::mapTransport(const std::string & un, const std::string & gn)
{
auto u = users->getEntry(un);
auto g = groups->getEntry(gn);
if (!u || !g) {
throw NetFS::SystemError(EPERM);
}
return {static_cast<int>(u->id), static_cast<int>(g->id), 0};
}
Transport
DefaultMapper::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};
}
}
|