Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
f466c6fd | 2 | #include "reiserfs.h" |
16f7e0fe | 3 | #include <linux/capability.h> |
1da177e4 LT |
4 | #include <linux/errno.h> |
5 | #include <linux/fs.h> | |
6 | #include <linux/pagemap.h> | |
7 | #include <linux/xattr.h> | |
c45ac888 | 8 | #include "xattr.h" |
17093991 | 9 | #include <linux/uaccess.h> |
1da177e4 | 10 | |
1da177e4 | 11 | static int |
b296821a AV |
12 | trusted_get(const struct xattr_handler *handler, struct dentry *unused, |
13 | struct inode *inode, const char *name, void *buffer, size_t size) | |
1da177e4 | 14 | { |
b296821a | 15 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
bd4c625c | 16 | return -EPERM; |
1da177e4 | 17 | |
b296821a | 18 | return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
79a628d1 | 19 | buffer, size); |
1da177e4 LT |
20 | } |
21 | ||
22 | static int | |
e65ce2a5 | 23 | trusted_set(const struct xattr_handler *handler, |
39f60c1c | 24 | struct mnt_idmap *idmap, struct dentry *unused, |
59301226 AV |
25 | struct inode *inode, const char *name, const void *buffer, |
26 | size_t size, int flags) | |
1da177e4 | 27 | { |
59301226 | 28 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
bd4c625c | 29 | return -EPERM; |
1da177e4 | 30 | |
59301226 | 31 | return reiserfs_xattr_set(inode, |
79a628d1 AV |
32 | xattr_full_name(handler, name), |
33 | buffer, size, flags); | |
1da177e4 LT |
34 | } |
35 | ||
764a5c6b | 36 | static bool trusted_list(struct dentry *dentry) |
1da177e4 | 37 | { |
764a5c6b | 38 | return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry)); |
1da177e4 LT |
39 | } |
40 | ||
94d09a98 | 41 | const struct xattr_handler reiserfs_xattr_trusted_handler = { |
1da177e4 LT |
42 | .prefix = XATTR_TRUSTED_PREFIX, |
43 | .get = trusted_get, | |
44 | .set = trusted_set, | |
1da177e4 LT |
45 | .list = trusted_list, |
46 | }; |