platform specific code to deal with sete{u,g}id. closes #17

This commit is contained in:
Antonio SJ Musumeci 2014-06-17 19:12:09 -04:00
parent 716453596a
commit 0e12d79659
39 changed files with 323 additions and 131 deletions

View file

@ -74,6 +74,14 @@ $(warning "xattr not available: disabling")
CFLAGS += -DWITHOUT_XATTR
endif
KERNEL = $(shell uname -s)
ifeq ($(KERNEL),Linux)
CFLAGS += -DLINUX
endif
ifeq ($(KERNEL),Darwin)
CFLAGS += -DOSX
endif
all: $(TARGET)
help:

View file

@ -70,8 +70,9 @@ namespace mergerfs
access(const char *fusepath,
int mask)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return _access(*config.search,

View file

@ -73,8 +73,9 @@ namespace mergerfs
chmod(const char *fusepath,
mode_t mode)
{
ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return -EPERM;

View file

@ -76,8 +76,9 @@ namespace mergerfs
uid_t uid,
gid_t gid)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EPERM;

View file

@ -76,7 +76,7 @@ _create(const fs::SearchFunc searchFunc,
createPathFunc(srcmounts,dirname,createpath);
if(createpath.empty())
return -ENOSPC;
if(createpath[0].base != existingpath[0].base)
fs::clonepath(existingpath[0].base,createpath[0].base,dirname);
@ -100,8 +100,9 @@ namespace mergerfs
mode_t mode,
struct fuse_file_info *fileinfo)
{
ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return _create_controlfile(fileinfo->fh);
@ -110,7 +111,7 @@ namespace mergerfs
*config.create,
config.srcmounts,
fusepath,
mode,
(mode & ~fc->umask),
fileinfo->flags,
fileinfo->fh);
}

View file

@ -31,7 +31,6 @@
#include <errno.h>
#include <fcntl.h>
#include "ugid.hpp"
#include "config.hpp"
#include "fileinfo.hpp"
@ -77,9 +76,8 @@ namespace mergerfs
off_t len,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
if(fusepath == config.controlfile)
return -EINVAL;

View file

@ -30,7 +30,6 @@
#include <errno.h>
#include "config.hpp"
#include "ugid.hpp"
#include "fileinfo.hpp"
static
@ -54,9 +53,8 @@ namespace mergerfs
struct stat *st,
struct fuse_file_info *ffi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
if(fusepath == config.controlfile)
return (*st = config.controlfilestat,0);

View file

@ -27,7 +27,6 @@
#include <unistd.h>
#include <errno.h>
#include "ugid.hpp"
#include "fileinfo.hpp"
static
@ -53,8 +52,6 @@ namespace mergerfs
flush(const char *path,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
return _flush(((FileInfo*)fi->fh)->fd);
}
}

View file

@ -35,7 +35,6 @@
#include <errno.h>
#include "config.hpp"
#include "ugid.hpp"
#include "fileinfo.hpp"
static
@ -61,9 +60,8 @@ namespace mergerfs
int isdatasync,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
if(fusepath == config.controlfile)
return 0;

View file

@ -29,7 +29,6 @@
#include <errno.h>
#include "config.hpp"
#include "ugid.hpp"
#include "fileinfo.hpp"
static
@ -53,9 +52,8 @@ namespace mergerfs
off_t size,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
if(fusepath == config.controlfile)
return -EPERM;

View file

@ -68,8 +68,9 @@ namespace mergerfs
getattr(const char *fusepath,
struct stat *buf)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return (*buf = config.controlfilestat,0);

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <string>
#include <vector>
@ -112,8 +114,9 @@ namespace mergerfs
char *buf,
size_t count)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return _getxattr_controlfile(config,

View file

@ -32,7 +32,6 @@
#include "config.hpp"
#include "fileinfo.hpp"
#include "ugid.hpp"
static
int
@ -86,9 +85,8 @@ namespace mergerfs
unsigned int flags,
void *data)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
if(fusepath == config.controlfile)
return -EINVAL;

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <string>
#include <vector>
@ -76,8 +78,9 @@ namespace mergerfs
link(const char *from,
const char *to)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(from == config.controlfile)
return -EPERM;

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <string>
#include <vector>
@ -101,8 +103,9 @@ namespace mergerfs
char *list,
size_t size)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return _listxattr_controlfile(list,

View file

@ -82,8 +82,9 @@ namespace mergerfs
mkdir(const char *fusepath,
mode_t mode)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EEXIST;
@ -92,7 +93,7 @@ namespace mergerfs
*config.create,
config.srcmounts,
fusepath,
mode);
(mode & ~fc->umask));
}
}
}

View file

@ -60,7 +60,7 @@ _mknod(const fs::SearchFunc searchFunc,
if(fs::path_exists(srcmounts,fusepath))
return -EEXIST;
dirname = fs::dirname(fusepath);
dirname = fs::dirname(fusepath);
searchFunc(srcmounts,dirname,existingpath);
if(existingpath.empty())
return -ENOENT;
@ -85,8 +85,9 @@ namespace mergerfs
mode_t mode,
dev_t rdev)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EEXIST;
@ -95,7 +96,7 @@ namespace mergerfs
*config.create,
config.srcmounts,
fusepath,
mode,
(mode & ~fc->umask),
rdev);
}
}

View file

@ -83,8 +83,9 @@ namespace mergerfs
open(const char *fusepath,
struct fuse_file_info *fileinfo)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);;
if(fusepath == config.controlfile)
return _open_controlfile(fileinfo->fh);

View file

@ -77,8 +77,7 @@ namespace mergerfs
off_t offset,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return _read_controlfile(config.readstr,

View file

@ -108,8 +108,7 @@ namespace mergerfs
off_t offset,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return _read_buf_controlfile(config.readstr,

View file

@ -122,8 +122,9 @@ namespace mergerfs
off_t offset,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
return _readdir(config.srcmounts,
fusepath,

View file

@ -72,8 +72,9 @@ namespace mergerfs
char *buf,
size_t size)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EINVAL;

View file

@ -71,8 +71,7 @@ namespace mergerfs
release(const char *fusepath,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return _release_controlfile(fi->fh);

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <string>
#include <vector>
@ -78,8 +80,9 @@ namespace mergerfs
removexattr(const char *fusepath,
const char *attrname)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -ENOTSUP;

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
@ -67,8 +69,9 @@ namespace mergerfs
rename(const char *from,
const char *to)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(from == config.controlfile)
return -ENOENT;

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <errno.h>
#include <unistd.h>
@ -70,8 +72,9 @@ namespace mergerfs
int
rmdir(const char *fusepath)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -ENOTDIR;

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <string>
#include <vector>
#include <sstream>
@ -146,8 +148,9 @@ namespace mergerfs
size_t attrvalsize,
int flags)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return _setxattr_controlfile(config::get_writable(),

View file

@ -124,8 +124,9 @@ namespace mergerfs
statfs(const char *fusepath,
struct statvfs *stat)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
return _statfs(config.srcmounts,
*stat);

View file

@ -64,8 +64,9 @@ namespace mergerfs
symlink(const char *oldpath,
const char *newpath)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(oldpath == config.controlfile ||
newpath == config.controlfile)

View file

@ -76,8 +76,9 @@ namespace mergerfs
truncate(const char *fusepath,
off_t size)
{
const ugid::SetResetGuard uid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EPERM;

31
src/ugid.cpp Normal file
View file

@ -0,0 +1,31 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "ugid.hpp"
#if defined LINUX
#elif defined OSX
#else
pthread_mutex_t mergerfs::ugid::SetResetGuard::lock = PTHREAD_MUTEX_INITIALIZER;
#endif

View file

@ -25,70 +25,12 @@
#ifndef __UGID_HPP__
#define __UGID_HPP__
#include <fuse.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
namespace mergerfs
{
namespace ugid
{
struct SetResetGuard
{
SetResetGuard()
{
const struct fuse_context *fc = fuse_get_context();
olduid = ::getuid();
oldgid = ::getgid();
oldumask = ::umask(fc->umask);
newuid = fc->uid;
newgid = fc->gid;
newumask = fc->umask;
if(olduid != newuid)
::seteuid(newuid);
if(oldgid != newgid)
::setegid(newgid);
}
SetResetGuard(uid_t u,
gid_t g,
mode_t m)
{
olduid = ::getuid();
oldgid = ::getgid();
oldumask = ::umask(m);
newuid = u;
newgid = g;
newumask = m;
if(olduid != newuid)
::seteuid(newuid);
if(oldgid != newgid)
::setegid(newgid);
}
~SetResetGuard()
{
::umask(oldumask);
if(olduid != newuid)
::seteuid(olduid);
if(oldgid != newgid)
::setegid(oldgid);
}
uid_t olduid;
gid_t oldgid;
mode_t oldumask;
uid_t newuid;
gid_t newgid;
mode_t newumask;
};
}
}
#if defined LINUX
#include "ugid_linux.hpp"
#elif defined OSX
#include "ugid_osx.hpp"
#else
#include "ugid_mutex.hpp"
#endif
#endif /* __UGID_HPP__ */

64
src/ugid_linux.hpp Normal file
View file

@ -0,0 +1,64 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/syscall.h>
namespace mergerfs
{
namespace ugid
{
struct SetResetGuard
{
SetResetGuard(const uid_t _newuid,
const gid_t _newgid)
{
olduid = ::geteuid();
oldgid = ::getegid();
newuid = _newuid;
newgid = _newgid;
if(newgid != oldgid)
::syscall(SYS_setregid,-1,newgid);
if(newuid != olduid)
::syscall(SYS_setreuid,-1,newuid);
}
~SetResetGuard()
{
if(olduid != newuid)
::syscall(SYS_setreuid,-1,olduid);
if(oldgid != newgid)
::syscall(SYS_setregid,-1,oldgid);
}
uid_t olduid;
gid_t oldgid;
uid_t newuid;
gid_t newgid;
};
}
}

68
src/ugid_mutex.hpp Normal file
View file

@ -0,0 +1,68 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
namespace mergerfs
{
namespace ugid
{
struct SetResetGuard
{
SetResetGuard(const uid_t _newuid,
const gid_t _newgid)
{
pthread_mutex_lock(&lock);
olduid = ::geteuid();
oldgid = ::getegid();
newuid = _newuid;
newgid = _newgid;
if(newgid != oldgid)
setegid(newgid);
if(newuid != olduid)
seteuid(newuid);
}
~SetResetGuard()
{
if(olduid != newuid)
seteuid(newuid);
if(oldgid != newgid)
setegid(newgid);
}
uid_t olduid;
gid_t oldgid;
uid_t newuid;
gid_t newgid;
static pthread_mutex_t lock;
};
}
}

58
src/ugid_osx.hpp Normal file
View file

@ -0,0 +1,58 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <sys/types.h>
#include <sys/unistd.h>
namespace mergerfs
{
namespace ugid
{
struct SetResetGuard
{
SetResetGuard(const uid_t _newuid,
const gid_t _newgid)
{
olduid = ::geteuid();
oldgid = ::getegid();
newuid = _newuid;
newgid = _newgid;
if(newgid != oldgid || newuid != olduid)
pthread_setugid_np(newuid,newgid);
}
~SetResetGuard()
{
if(newgid != oldgid || newuid != olduid)
pthread_setugid_np(newuid,newgid);
}
uid_t olduid;
gid_t oldgid;
uid_t newuid;
gid_t newgid;
};
}
}

View file

@ -22,6 +22,8 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <errno.h>
#include <unistd.h>
@ -71,8 +73,9 @@ namespace mergerfs
int
unlink(const char *fusepath)
{
const ugid::SetResetGuard ugid;
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EPERM;

View file

@ -22,8 +22,11 @@
THE SOFTWARE.
*/
#include <fuse.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string>
#include <vector>
@ -31,7 +34,6 @@
#include "ugid.hpp"
#include "fs.hpp"
#include "config.hpp"
#include "assert.hpp"
using std::string;
using std::vector;
@ -73,8 +75,9 @@ namespace mergerfs
utimens(const char *fusepath,
const struct timespec ts[2])
{
ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
if(fusepath == config.controlfile)
return -EPERM;

View file

@ -128,8 +128,7 @@ namespace mergerfs
off_t offset,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return _write_controlfile(config::get_writable(),

View file

@ -28,7 +28,6 @@
#include <fuse.h>
#include "config.hpp"
#include "ugid.hpp"
#include "fileinfo.hpp"
#include "write.hpp"
@ -93,8 +92,7 @@ namespace mergerfs
off_t offset,
struct fuse_file_info *fi)
{
const ugid::SetResetGuard ugid;
const config::Config &config = config::get();
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return _write_buf_controlfile(config.controlfile,