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.20/fs/ext3/xattr.c
7 ===================================================================
8 --- linux-2.4.20.orig/fs/ext3/xattr.c 2003-10-22 02:29:40.000000000 +0400
9 +++ linux-2.4.20/fs/ext3/xattr.c 2003-10-24 01:03:22.000000000 +0400
10 @@ -1771,18 +1771,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 @@ -1793,12 +1800,13 @@
42 + return init_ext3_xattr_trusted();
48 + exit_ext3_xattr_trusted();
51 #endif /* CONFIG_EXT3_FS_XATTR_SHARING */
52 Index: linux-2.4.20/fs/ext3/xattr_trusted.c
53 ===================================================================
54 --- linux-2.4.20.orig/fs/ext3/xattr_trusted.c 2003-10-24 01:03:22.000000000 +0400
55 +++ linux-2.4.20/fs/ext3/xattr_trusted.c 2003-10-24 01:03:22.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.20/include/linux/ext3_xattr.h
144 ===================================================================
145 --- linux-2.4.20.orig/include/linux/ext3_xattr.h 2003-10-22 02:29:39.000000000 +0400
146 +++ linux-2.4.20/include/linux/ext3_xattr.h 2003-10-24 01:03:22.000000000 +0400
148 #define EXT3_XATTR_INDEX_USER 1
149 #define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
150 #define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
151 +#define EXT3_XATTR_INDEX_TRUSTED 4
152 +#define EXT3_XATTR_INDEX_LUSTRE 5
153 +#define EXT3_XATTR_INDEX_SECURITY 6
155 struct ext3_xattr_header {
156 __u32 h_magic; /* magic number for identification */
158 extern int init_ext3_xattr(void) __init;
159 extern void exit_ext3_xattr(void);
161 +extern int init_ext3_xattr_trusted(void) __init;
162 +extern void exit_ext3_xattr_trusted(void);
164 # else /* CONFIG_EXT3_FS_XATTR */
165 # define ext3_setxattr NULL
166 # define ext3_getxattr NULL
167 Index: linux-2.4.20/fs/ext3/Makefile
168 ===================================================================
169 --- linux-2.4.20.orig/fs/ext3/Makefile 2003-10-22 02:29:40.000000000 +0400
170 +++ linux-2.4.20/fs/ext3/Makefile 2003-10-24 01:03:47.000000000 +0400
172 export-objs := ext3-exports.o
174 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
175 - ioctl.o namei.o super.o symlink.o hash.o ext3-exports.o
176 + ioctl.o namei.o super.o symlink.o hash.o ext3-exports.o \
180 export-objs += xattr.o