mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-05 14:20:03 -05:00
add security_capability option
This commit is contained in:
parent
4152769182
commit
f8563369bc
8 changed files with 54 additions and 8 deletions
|
|
@ -45,6 +45,7 @@ namespace mergerfs
|
|||
symlinkify_timeout(3600),
|
||||
nullrw(false),
|
||||
ignorepponrename(false),
|
||||
security_capability(true),
|
||||
POLICYINIT(access),
|
||||
POLICYINIT(chmod),
|
||||
POLICYINIT(chown),
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ namespace mergerfs
|
|||
time_t symlinkify_timeout;
|
||||
bool nullrw;
|
||||
bool ignorepponrename;
|
||||
bool security_capability;
|
||||
|
||||
public:
|
||||
const Policy *policies[FuseFunc::Enum::END];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
Copyright (c) 2018, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
@ -34,11 +34,20 @@
|
|||
#include "ugid.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
static const char SECURITY_CAPABILITY[] = "security.capability";
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::set;
|
||||
using namespace mergerfs;
|
||||
|
||||
static
|
||||
bool
|
||||
_is_attrname_security_capability(const char *attrname_)
|
||||
{
|
||||
return (strcmp(attrname_,SECURITY_CAPABILITY) == 0);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_lgetxattr(const string &path,
|
||||
|
|
@ -199,6 +208,8 @@ _getxattr_controlfile(const Config &config,
|
|||
_getxattr_controlfile_bool(config.nullrw,attrvalue);
|
||||
else if(attr[2] == "ignorepponrename")
|
||||
_getxattr_controlfile_bool(config.ignorepponrename,attrvalue);
|
||||
else if(attr[2] == "security_capability")
|
||||
_getxattr_controlfile_bool(config.security_capability,attrvalue);
|
||||
else if(attr[2] == "policies")
|
||||
_getxattr_controlfile_policies(config,attrvalue);
|
||||
else if(attr[2] == "version")
|
||||
|
|
@ -334,6 +345,10 @@ namespace mergerfs
|
|||
const fuse_context *fc = fuse_get_context();
|
||||
const Config &config = Config::get(fc);
|
||||
|
||||
if((config.security_capability == false) &&
|
||||
_is_attrname_security_capability(attrname))
|
||||
return -ENOATTR;
|
||||
|
||||
if(fusepath == config.controlfile)
|
||||
return _getxattr_controlfile(config,
|
||||
attrname,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ _listxattr_controlfile(char *list,
|
|||
("user.mergerfs.symlinkify_timeout")
|
||||
("user.mergerfs.nullrw")
|
||||
("user.mergerfs.ignorepponrename")
|
||||
("user.mergerfs.security_capability")
|
||||
("user.mergerfs.policies")
|
||||
("user.mergerfs.version")
|
||||
("user.mergerfs.pid");
|
||||
|
|
|
|||
|
|
@ -194,6 +194,8 @@ parse_and_process_kv_arg(Config &config,
|
|||
rv = parse_and_process(value,config.nullrw);
|
||||
else if(key == "ignorepponrename")
|
||||
rv = parse_and_process(value,config.ignorepponrename);
|
||||
else if(key == "security_capability")
|
||||
rv = parse_and_process(value,config.security_capability);
|
||||
}
|
||||
|
||||
if(rv == -1)
|
||||
|
|
@ -282,23 +284,26 @@ usage(void)
|
|||
" -o use_ino Have mergerfs generate inode values rather than\n"
|
||||
" autogenerated by libfuse. Suggested.\n"
|
||||
" -o minfreespace=<int> minimum free space needed for certain policies.\n"
|
||||
" default=4G\n"
|
||||
" default = 4G\n"
|
||||
" -o moveonenospc=<bool> Try to move file to another drive when ENOSPC\n"
|
||||
" on write. default=false\n"
|
||||
" on write. default = false\n"
|
||||
" -o dropcacheonclose=<bool>\n"
|
||||
" When a file is closed suggest to OS it drop\n"
|
||||
" the file's cache. This is useful when direct_io\n"
|
||||
" is disabled. default=false\n"
|
||||
" is disabled. default = false\n"
|
||||
" -o symlinkify=<bool> Read-only files, after a timeout, will be turned\n"
|
||||
" into symlinks. Read docs for limitations and\n"
|
||||
" possible issues. default=false\n"
|
||||
" possible issues. default = false\n"
|
||||
" -o symlinkify_timeout=<int>\n"
|
||||
" timeout in seconds before will turn to symlinks.\n"
|
||||
" default=3600\n"
|
||||
" default = 3600\n"
|
||||
" -o nullrw=<bool> Disables reads and writes. For benchmarking.\n"
|
||||
" -o ignorepponrename=<bool>\n"
|
||||
" Ignore path preserving when performing renames\n"
|
||||
" and links. default = false\n"
|
||||
" -o security_capability=<bool>\n"
|
||||
" When disabled return ENOATTR when the xattr\n"
|
||||
" security.capability is queried. default = true\n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -297,6 +297,10 @@ _setxattr_controlfile(Config &config,
|
|||
return _setxattr_bool(attrval,
|
||||
flags,
|
||||
config.ignorepponrename);
|
||||
else if(attr[2] == "security_capability")
|
||||
return _setxattr_bool(attrval,
|
||||
flags,
|
||||
config.security_capability);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue