Browse Source

Merge pull request #66 from trapexit/pseudo-file-permissions

restrict who can setxattr the pseudo file. closes #64
pull/67/head
Antonio SJ Musumeci 10 years ago
parent
commit
7552ad6781
  1. 6
      src/getattr.cpp
  2. 7
      src/setxattr.cpp

6
src/getattr.cpp

@ -48,10 +48,10 @@ _getattr_controlfile(struct stat &buf)
buf.st_dev = 0; buf.st_dev = 0;
buf.st_ino = 0; buf.st_ino = 0;
buf.st_mode = (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
buf.st_mode = (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
buf.st_nlink = 1; buf.st_nlink = 1;
buf.st_uid = ::geteuid();
buf.st_gid = ::getegid();
buf.st_uid = ::getuid();
buf.st_gid = ::getgid();
buf.st_rdev = 0; buf.st_rdev = 0;
buf.st_size = 0; buf.st_size = 0;
buf.st_blksize = 1024; buf.st_blksize = 1024;

7
src/setxattr.cpp

@ -283,15 +283,20 @@ namespace mergerfs
int flags) int flags)
{ {
const config::Config &config = config::get(); const config::Config &config = config::get();
const struct fuse_context *fc = fuse_get_context();
if(fusepath == config.controlfile) if(fusepath == config.controlfile)
{
if((fc->uid != ::getuid()) && (fc->gid != ::getgid()))
return -EPERM;
return _setxattr_controlfile(config::get_writable(), return _setxattr_controlfile(config::get_writable(),
attrname, attrname,
string(attrval,attrvalsize), string(attrval,attrvalsize),
flags); flags);
}
{ {
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid); const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock); const rwlock::ReadGuard readlock(&config.srcmountslock);

Loading…
Cancel
Save