0001
0002 #include "reiserfs.h"
0003 #include <linux/capability.h>
0004 #include <linux/errno.h>
0005 #include <linux/fs.h>
0006 #include <linux/pagemap.h>
0007 #include <linux/xattr.h>
0008 #include "xattr.h"
0009 #include <linux/uaccess.h>
0010
0011 static int
0012 trusted_get(const struct xattr_handler *handler, struct dentry *unused,
0013 struct inode *inode, const char *name, void *buffer, size_t size)
0014 {
0015 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
0016 return -EPERM;
0017
0018 return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
0019 buffer, size);
0020 }
0021
0022 static int
0023 trusted_set(const struct xattr_handler *handler,
0024 struct user_namespace *mnt_userns, struct dentry *unused,
0025 struct inode *inode, const char *name, const void *buffer,
0026 size_t size, int flags)
0027 {
0028 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
0029 return -EPERM;
0030
0031 return reiserfs_xattr_set(inode,
0032 xattr_full_name(handler, name),
0033 buffer, size, flags);
0034 }
0035
0036 static bool trusted_list(struct dentry *dentry)
0037 {
0038 return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
0039 }
0040
0041 const struct xattr_handler reiserfs_xattr_trusted_handler = {
0042 .prefix = XATTR_TRUSTED_PREFIX,
0043 .get = trusted_get,
0044 .set = trusted_set,
0045 .list = trusted_list,
0046 };