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.18-chaos/fs/ext3/xattr.c
7 ===================================================================
8 --- linux-2.4.18-chaos.orig/fs/ext3/xattr.c 2003-10-22 14:23:53.000000000 +0400
9 +++ linux-2.4.18-chaos/fs/ext3/xattr.c 2003-10-24 01:01:03.000000000 +0400
10 @@ -1789,18 +1789,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 @@ -1811,12 +1818,13 @@
42 + return init_ext3_xattr_trusted();
48 + exit_ext3_xattr_trusted();
51 #endif /* CONFIG_EXT3_FS_XATTR_SHARING */
52 Index: linux-2.4.18-chaos/fs/ext3/xattr_trusted.c
53 ===================================================================
54 --- linux-2.4.18-chaos.orig/fs/ext3/xattr_trusted.c 2003-10-24 01:01:03.000000000 +0400
55 +++ linux-2.4.18-chaos/fs/ext3/xattr_trusted.c 2003-10-24 01:01:03.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.18-chaos/include/linux/ext3_xattr.h
144 ===================================================================
145 --- linux-2.4.18-chaos.orig/include/linux/ext3_xattr.h 2003-10-22 14:23:51.000000000 +0400
146 +++ linux-2.4.18-chaos/include/linux/ext3_xattr.h 2003-10-24 01:01:03.000000000 +0400
149 #define EXT3_XATTR_INDEX_MAX 10
150 #define EXT3_XATTR_INDEX_USER 1
151 +#define EXT3_XATTR_INDEX_TRUSTED 4
152 +#define EXT3_XATTR_INDEX_LUSTRE 5
153 +#define EXT3_XATTR_INDEX_SECURITY 6
156 struct ext3_xattr_header {
157 __u32 h_magic; /* magic number for identification */
159 extern int init_ext3_xattr(void) __init;
160 extern void exit_ext3_xattr(void);
162 +extern int init_ext3_xattr_trusted(void) __init;
163 +extern void exit_ext3_xattr_trusted(void);
165 # else /* CONFIG_EXT3_FS_XATTR */
166 # define ext3_setxattr NULL
167 # define ext3_getxattr NULL
168 Index: linux-2.4.18-chaos/fs/ext3/Makefile
169 ===================================================================
170 --- linux-2.4.18-chaos.orig/fs/ext3/Makefile 2003-10-22 14:23:53.000000000 +0400
171 +++ linux-2.4.18-chaos/fs/ext3/Makefile 2003-10-24 01:02:28.000000000 +0400
174 obj-y := balloc.o iopen.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
175 ioctl.o namei.o super.o symlink.o xattr.o ext3-exports.o \
177 + extents.o xattr_trusted.o
180 include $(TOPDIR)/Rules.make