2012-03-17 13:16:43 +08:00
|
|
|
#include "reiserfs.h"
|
2006-01-12 04:17:46 +08:00
|
|
|
#include <linux/capability.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/xattr.h>
|
2012-03-17 12:59:06 +08:00
|
|
|
#include "xattr.h"
|
2014-08-09 05:21:12 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int
|
2016-04-11 08:48:24 +08:00
|
|
|
trusted_get(const struct xattr_handler *handler, struct dentry *unused,
|
|
|
|
struct inode *inode, const char *name, void *buffer, size_t size)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-04-11 08:48:24 +08:00
|
|
|
if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
|
2005-07-13 11:21:28 +08:00
|
|
|
return -EPERM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-04-11 08:48:24 +08:00
|
|
|
return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
|
2016-04-11 06:50:48 +08:00
|
|
|
buffer, size);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-05-27 22:19:30 +08:00
|
|
|
trusted_set(const struct xattr_handler *handler, struct dentry *unused,
|
|
|
|
struct inode *inode, const char *name, const void *buffer,
|
|
|
|
size_t size, int flags)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-05-27 22:19:30 +08:00
|
|
|
if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
|
2005-07-13 11:21:28 +08:00
|
|
|
return -EPERM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-05-27 22:19:30 +08:00
|
|
|
return reiserfs_xattr_set(inode,
|
2016-04-11 06:50:48 +08:00
|
|
|
xattr_full_name(handler, name),
|
|
|
|
buffer, size, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2015-12-02 21:44:43 +08:00
|
|
|
static bool trusted_list(struct dentry *dentry)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2015-12-02 21:44:43 +08:00
|
|
|
return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-05-14 08:53:19 +08:00
|
|
|
const struct xattr_handler reiserfs_xattr_trusted_handler = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.prefix = XATTR_TRUSTED_PREFIX,
|
|
|
|
.get = trusted_get,
|
|
|
|
.set = trusted_set,
|
|
|
|
.list = trusted_list,
|
|
|
|
};
|