Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * linux/fs/ext2/xattr_trusted.c |
| 4 | * Handler for trusted extended attributes. |
| 5 | * |
| 6 | * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org> |
| 7 | */ |
| 8 | |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 9 | #include "ext2.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include "xattr.h" |
| 11 | |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 12 | static bool |
| 13 | ext2_xattr_trusted_list(struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | { |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 15 | return capable(CAP_SYS_ADMIN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 19 | ext2_xattr_trusted_get(const struct xattr_handler *handler, |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 20 | struct dentry *unused, struct inode *inode, |
| 21 | const char *name, void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | { |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 23 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | buffer, size); |
| 25 | } |
| 26 | |
| 27 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 28 | ext2_xattr_trusted_set(const struct xattr_handler *handler, |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 29 | struct dentry *unused, struct inode *inode, |
| 30 | const char *name, const void *value, |
| 31 | size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 33 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | value, size, flags); |
| 35 | } |
| 36 | |
Stephen Hemminger | 749c72ef | 2010-05-13 17:53:16 -0700 | [diff] [blame] | 37 | const struct xattr_handler ext2_xattr_trusted_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | .prefix = XATTR_TRUSTED_PREFIX, |
| 39 | .list = ext2_xattr_trusted_list, |
| 40 | .get = ext2_xattr_trusted_get, |
| 41 | .set = ext2_xattr_trusted_set, |
| 42 | }; |