diff options
author | Jim Owens <jowens@hp.com> | 2009-02-04 09:29:13 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-02-04 09:29:13 -0500 |
commit | 0279b4cd86685b5eea467c1b74ce94f0add2c0a3 (patch) | |
tree | 54caafd4c6b31e2bc9861217627297c00af89066 /fs/btrfs/xattr.c | |
parent | bef62ef339c15d7721da88958b03f7b544464722 (diff) |
Btrfs: selinux support
Add call to LSM security initialization and save
resulting security xattr for new inodes.
Add xattr support to symlink inode ops.
Set inode->i_op for existing special files.
Signed-off-by: jim owens <jowens@hp.com>
Diffstat (limited to 'fs/btrfs/xattr.c')
-rw-r--r-- | fs/btrfs/xattr.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index b4fa5f4b6ad1..312b9435e9f8 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/rwsem.h> | 22 | #include <linux/rwsem.h> |
23 | #include <linux/xattr.h> | 23 | #include <linux/xattr.h> |
24 | #include <linux/security.h> | ||
24 | #include "ctree.h" | 25 | #include "ctree.h" |
25 | #include "btrfs_inode.h" | 26 | #include "btrfs_inode.h" |
26 | #include "transaction.h" | 27 | #include "transaction.h" |
@@ -330,3 +331,34 @@ int btrfs_removexattr(struct dentry *dentry, const char *name) | |||
330 | return -EOPNOTSUPP; | 331 | return -EOPNOTSUPP; |
331 | return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); | 332 | return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); |
332 | } | 333 | } |
334 | |||
335 | int btrfs_xattr_security_init(struct inode *inode, struct inode *dir) | ||
336 | { | ||
337 | int err; | ||
338 | size_t len; | ||
339 | void *value; | ||
340 | char *suffix; | ||
341 | char *name; | ||
342 | |||
343 | err = security_inode_init_security(inode, dir, &suffix, &value, &len); | ||
344 | if (err) { | ||
345 | if (err == -EOPNOTSUPP) | ||
346 | return 0; | ||
347 | return err; | ||
348 | } | ||
349 | |||
350 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + strlen(suffix) + 1, | ||
351 | GFP_NOFS); | ||
352 | if (!name) { | ||
353 | err = -ENOMEM; | ||
354 | } else { | ||
355 | strcpy(name, XATTR_SECURITY_PREFIX); | ||
356 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); | ||
357 | err = __btrfs_setxattr(inode, name, value, len, 0); | ||
358 | kfree(name); | ||
359 | } | ||
360 | |||
361 | kfree(suffix); | ||
362 | kfree(value); | ||
363 | return err; | ||
364 | } | ||