blob: 49add11078507d22edc7fe51b8948535d3a5db04 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 Virof7699f22012-03-23 16:45:51 -04009#include "ext2.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include "xattr.h"
11
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010012static bool
13ext2_xattr_trusted_list(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014{
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010015 return capable(CAP_SYS_ADMIN);
Linus Torvalds1da177e2005-04-16 15:20:36 -070016}
17
18static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020019ext2_xattr_trusted_get(const struct xattr_handler *handler,
Al Virob2968212016-04-10 20:48:24 -040020 struct dentry *unused, struct inode *inode,
21 const char *name, void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022{
Al Virob2968212016-04-10 20:48:24 -040023 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 buffer, size);
25}
26
27static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020028ext2_xattr_trusted_set(const struct xattr_handler *handler,
Al Viro59301222016-05-27 10:19:30 -040029 struct dentry *unused, struct inode *inode,
30 const char *name, const void *value,
31 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
Al Viro59301222016-05-27 10:19:30 -040033 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 value, size, flags);
35}
36
Stephen Hemminger749c72ef2010-05-13 17:53:16 -070037const struct xattr_handler ext2_xattr_trusted_handler = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 .prefix = XATTR_TRUSTED_PREFIX,
39 .list = ext2_xattr_trusted_list,
40 .get = ext2_xattr_trusted_get,
41 .set = ext2_xattr_trusted_set,
42};