Set uid and gid

This commit is contained in:
Les De Ridder 2016-10-16 05:26:45 +02:00
parent 4fcf700dab
commit 6e5c10d60e
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
1 changed files with 13 additions and 2 deletions

View File

@ -9,6 +9,8 @@ import std.array;
import std.string;
import std.stdio;
import core.sys.posix.unistd;
import dfuse.fuse;
import dtagfs.tagprovider;
@ -18,6 +20,9 @@ class FileSystem : Operations
private string _source;
private TagProvider[] _tagProviders;
private uid_t _uid;
private gid_t _gid;
private string[][string] _tagCache;
this(string source, TagProvider[] tagProviders)
@ -25,6 +30,9 @@ class FileSystem : Operations
_source = source;
_tagProviders = tagProviders;
_uid = getuid();
_gid = getgid();
cacheTags();
}
@ -47,9 +55,12 @@ class FileSystem : Operations
override void getattr(const(char)[] path, ref stat_t stat)
{
stat.st_uid = _uid;
stat.st_gid = _gid;
if(path == "/" || isTag(path.baseName))
{
stat.st_mode = S_IFDIR | octal!500;
stat.st_mode = S_IFDIR | octal!555;
stat.st_size = 0;
return;
}
@ -58,7 +69,7 @@ class FileSystem : Operations
auto file = findFile(path.baseName);
lstat(toStringz(file), &stat);
stat.st_mode = S_IFREG | octal!400;
stat.st_mode = S_IFREG | octal!444;
return;
}