1 fs/ext3/xattr.c | 12 +++++-
2 fs/ext3/xattr_trusted.c | 86 +++++++++++++++++++++++++++++++++++++++++++++
3 include/linux/ext3_xattr.h | 6 +++
4 3 files changed, 102 insertions(+), 2 deletions(-)
6 Index: linux-2.4.19/fs/ext3/xattr.c
7 ===================================================================
8 --- linux-2.4.19.orig/fs/ext3/xattr.c 2004-04-23 22:44:57.000000000 -0400
9 +++ linux-2.4.19/fs/ext3/xattr.c 2004-04-23 22:45:20.000000000 -0400
10 @@ -1785,18 +1785,25 @@
16 ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
17 sizeof(struct mb_cache_entry) +
18 sizeof(struct mb_cache_entry_index), 1, 61);
19 if (!ext3_xattr_cache)
23 + error = init_ext3_xattr_trusted();
25 + mb_cache_destroy(ext3_xattr_cache);
33 + exit_ext3_xattr_trusted();
35 mb_cache_destroy(ext3_xattr_cache);
36 ext3_xattr_cache = NULL;
37 @@ -1807,12 +1814,13 @@
42 + return init_ext3_xattr_trusted();
48 + exit_ext3_xattr_trusted();
51 #endif /* CONFIG_EXT3_FS_XATTR_SHARING */
52 Index: linux-2.4.19/fs/ext3/xattr_trusted.c
53 ===================================================================
54 --- linux-2.4.19.orig/fs/ext3/xattr_trusted.c 2003-01-30 05:24:37.000000000 -0500
55 +++ linux-2.4.19/fs/ext3/xattr_trusted.c 2004-04-23 22:45:20.000000000 -0400
58 + * linux/fs/ext3/xattr_trusted.c
59 + * Handler for trusted extended attributes.
61 + * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
64 +#include <linux/module.h>
65 +#include <linux/string.h>
66 +#include <linux/fs.h>
67 +#include <linux/ext3_jbd.h>
68 +#include <linux/ext3_fs.h>
69 +#include <linux/ext3_xattr.h>
71 +#define XATTR_TRUSTED_PREFIX "trusted."
74 +ext3_xattr_trusted_list(char *list, struct inode *inode,
75 + const char *name, int name_len)
77 + const int prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
79 + if (!capable(CAP_SYS_ADMIN))
83 + memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
84 + memcpy(list+prefix_len, name, name_len);
85 + list[prefix_len + name_len] = '\0';
87 + return prefix_len + name_len + 1;
91 +ext3_xattr_trusted_get(struct inode *inode, const char *name,
92 + void *buffer, size_t size)
94 + if (strcmp(name, "") == 0)
96 + if (!capable(CAP_SYS_ADMIN))
98 + return ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name,
103 +ext3_xattr_trusted_set(struct inode *inode, const char *name,
104 + const void *value, size_t size, int flags)
109 + if (strcmp(name, "") == 0)
111 + if (!capable(CAP_SYS_ADMIN))
113 + handle = ext3_journal_start(inode, EXT3_XATTR_TRANS_BLOCKS);
114 + if (IS_ERR(handle))
115 + return PTR_ERR(handle);
116 + error = ext3_xattr_set(handle, inode, EXT3_XATTR_INDEX_TRUSTED, name,
117 + value, size, flags);
118 + ext3_journal_stop(handle, inode);
123 +struct ext3_xattr_handler ext3_xattr_trusted_handler = {
124 + .prefix = XATTR_TRUSTED_PREFIX,
125 + .list = ext3_xattr_trusted_list,
126 + .get = ext3_xattr_trusted_get,
127 + .set = ext3_xattr_trusted_set,
131 +init_ext3_xattr_trusted(void)
133 + return ext3_xattr_register(EXT3_XATTR_INDEX_TRUSTED,
134 + &ext3_xattr_trusted_handler);
138 +exit_ext3_xattr_trusted(void)
140 + ext3_xattr_unregister(EXT3_XATTR_INDEX_TRUSTED,
141 + &ext3_xattr_trusted_handler);
143 Index: linux-2.4.19/fs/ext3/Makefile
144 ===================================================================
145 --- linux-2.4.19.orig/fs/ext3/Makefile 2004-04-23 22:38:38.000000000 -0400
146 +++ linux-2.4.19/fs/ext3/Makefile 2004-04-23 22:49:23.000000000 -0400
148 export-objs := super.o inode.o
150 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
151 - ioctl.o namei.o super.o symlink.o hash.o
152 + ioctl.o namei.o super.o symlink.o hash.o xattr_trusted.o
155 obj-$(CONFIG_EXT3_FS_XATTR) += xattr.o
156 Index: linux-2.4.19/include/linux/ext3_xattr.h
157 ===================================================================
158 --- linux-2.4.19.orig/include/linux/ext3_xattr.h 2004-04-23 17:53:54.000000000 -0400
159 +++ linux-2.4.19/include/linux/ext3_xattr.h 2004-04-23 22:45:20.000000000 -0400
161 #define EXT3_XATTR_INDEX_USER 1
162 #define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
163 #define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
164 +#define EXT3_XATTR_INDEX_TRUSTED 4
165 +#define EXT3_XATTR_INDEX_LUSTRE 5
166 +#define EXT3_XATTR_INDEX_SECURITY 6
168 struct ext3_xattr_header {
169 __u32 h_magic; /* magic number for identification */
171 extern int init_ext3_xattr(void) __init;
172 extern void exit_ext3_xattr(void);
174 +extern int init_ext3_xattr_trusted(void) __init;
175 +extern void exit_ext3_xattr_trusted(void);
177 # else /* CONFIG_EXT3_FS_XATTR */
178 # define ext3_setxattr NULL
179 # define ext3_getxattr NULL