aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/xattr_trusted.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/xattr_trusted.c')
-rw-r--r--fs/reiserfs/xattr_trusted.c45
1 files changed, 11 insertions, 34 deletions
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index 60abe2bb1f98..a865042f75e2 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -13,10 +13,7 @@ trusted_get(struct inode *inode, const char *name, void *buffer, size_t size)
13 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) 13 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
14 return -EINVAL; 14 return -EINVAL;
15 15
16 if (!reiserfs_xattrs(inode->i_sb)) 16 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
17 return -EOPNOTSUPP;
18
19 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
20 return -EPERM; 17 return -EPERM;
21 18
22 return reiserfs_xattr_get(inode, name, buffer, size); 19 return reiserfs_xattr_get(inode, name, buffer, size);
@@ -29,50 +26,30 @@ trusted_set(struct inode *inode, const char *name, const void *buffer,
29 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) 26 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
30 return -EINVAL; 27 return -EINVAL;
31 28
32 if (!reiserfs_xattrs(inode->i_sb)) 29 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
33 return -EOPNOTSUPP;
34
35 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
36 return -EPERM; 30 return -EPERM;
37 31
38 return reiserfs_xattr_set(inode, name, buffer, size, flags); 32 return reiserfs_xattr_set(inode, name, buffer, size, flags);
39} 33}
40 34
41static int trusted_del(struct inode *inode, const char *name) 35static size_t trusted_list(struct inode *inode, char *list, size_t list_size,
36 const char *name, size_t name_len)
42{ 37{
43 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) 38 const size_t len = name_len + 1;
44 return -EINVAL;
45 39
46 if (!reiserfs_xattrs(inode->i_sb)) 40 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
47 return -EOPNOTSUPP;
48
49 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
50 return -EPERM;
51
52 return 0;
53}
54
55static int
56trusted_list(struct inode *inode, const char *name, int namelen, char *out)
57{
58 int len = namelen;
59
60 if (!reiserfs_xattrs(inode->i_sb))
61 return 0; 41 return 0;
62 42
63 if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) 43 if (list && len <= list_size) {
64 return 0; 44 memcpy(list, name, name_len);
65 45 list[name_len] = '\0';
66 if (out) 46 }
67 memcpy(out, name, len);
68
69 return len; 47 return len;
70} 48}
71 49
72struct reiserfs_xattr_handler trusted_handler = { 50struct xattr_handler reiserfs_xattr_trusted_handler = {
73 .prefix = XATTR_TRUSTED_PREFIX, 51 .prefix = XATTR_TRUSTED_PREFIX,
74 .get = trusted_get, 52 .get = trusted_get,
75 .set = trusted_set, 53 .set = trusted_set,
76 .del = trusted_del,
77 .list = trusted_list, 54 .list = trusted_list,
78}; 55};