mirror of https://github.com/trapexit/mergerfs.git
98 lines
2.5 KiB
98 lines
2.5 KiB
/*
|
|
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
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#include "errno.hpp"
|
|
#include "fs_findallfiles.hpp"
|
|
#include "fs_lgetxattr.hpp"
|
|
#include "fs_path.hpp"
|
|
#include "fs_statvfs_cache.hpp"
|
|
#include "str.hpp"
|
|
#include "ugid.hpp"
|
|
#include "state.hpp"
|
|
#include "version.hpp"
|
|
|
|
#include "fuse.h"
|
|
|
|
#include <algorithm>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static const char SECURITY_CAPABILITY[] = "security.capability";
|
|
|
|
using std::string;
|
|
|
|
|
|
namespace l
|
|
{
|
|
static
|
|
bool
|
|
is_attrname_security_capability(const char *attrname_)
|
|
{
|
|
return (strcmp(attrname_,SECURITY_CAPABILITY) == 0);
|
|
}
|
|
}
|
|
|
|
namespace FUSE::GETXATTR
|
|
{
|
|
int
|
|
getxattr2(const char *fusepath_,
|
|
const char *attrname_,
|
|
char *buf_,
|
|
size_t count_)
|
|
{
|
|
return 0;
|
|
// Config::Read cfg;
|
|
|
|
// if((cfg->security_capability == false) &&
|
|
// l::is_attrname_security_capability(attrname_))
|
|
// return -ENOATTR;
|
|
|
|
// if(cfg->xattr.to_int())
|
|
// return -cfg->xattr.to_int();
|
|
|
|
// const fuse_context *fc = fuse_get_context();
|
|
// const ugid::Set ugid(fc->uid,fc->gid);
|
|
|
|
// return l::getxattr(cfg->func.getxattr.policy,
|
|
// cfg->branches,
|
|
// fusepath_,
|
|
// attrname_,
|
|
// buf_,
|
|
// count_);
|
|
}
|
|
|
|
int
|
|
getxattr(const char *fusepath_,
|
|
const char *attrname_,
|
|
char *buf_,
|
|
size_t count_)
|
|
{
|
|
State s;
|
|
gfs::path fusepath;
|
|
|
|
fusepath = &fusepath_[1];
|
|
if((s->security_capability == false) && l::is_attrname_security_capability(attrname_))
|
|
return -ENOATTR;
|
|
|
|
const fuse_context *fc = fuse_get_context();
|
|
const ugid::Set ugid(fc->uid,fc->gid);
|
|
|
|
return s->getxattr(fusepath,attrname_,buf_,count_);
|
|
}
|
|
}
|