Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Security xattr support for devpts. |
| 3 | * |
| 4 | * Author: Stephen Smalley <sds@epoch.ncsc.mil> |
| 5 | * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | */ |
| 12 | #include <linux/string.h> |
| 13 | #include <linux/fs.h> |
| 14 | #include <linux/security.h> |
| 15 | #include <linux/xattr.h> |
| 16 | |
| 17 | static size_t |
| 18 | devpts_xattr_security_list(struct inode *inode, char *list, size_t list_len, |
| 19 | const char *name, size_t name_len) |
| 20 | { |
| 21 | return security_inode_listsecurity(inode, list, list_len); |
| 22 | } |
| 23 | |
| 24 | static int |
| 25 | devpts_xattr_security_get(struct inode *inode, const char *name, |
| 26 | void *buffer, size_t size) |
| 27 | { |
| 28 | if (strcmp(name, "") == 0) |
| 29 | return -EINVAL; |
| 30 | return security_inode_getsecurity(inode, name, buffer, size); |
| 31 | } |
| 32 | |
| 33 | static int |
| 34 | devpts_xattr_security_set(struct inode *inode, const char *name, |
| 35 | const void *value, size_t size, int flags) |
| 36 | { |
| 37 | if (strcmp(name, "") == 0) |
| 38 | return -EINVAL; |
| 39 | return security_inode_setsecurity(inode, name, value, size, flags); |
| 40 | } |
| 41 | |
| 42 | struct xattr_handler devpts_xattr_security_handler = { |
| 43 | .prefix = XATTR_SECURITY_PREFIX, |
| 44 | .list = devpts_xattr_security_list, |
| 45 | .get = devpts_xattr_security_get, |
| 46 | .set = devpts_xattr_security_set, |
| 47 | }; |