Package: e2fsprogs / 1.47.2-3~bpo12+1

0008-fuse2fs-remove-posix-acl-translation.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
From: "Darrick J. Wong" <djwong@kernel.org>
Subject: fuse2fs: remove posix acl translation

Remove the POSIX ACL format translation since libext2fs takes care of
that now.

Fixes: 0ee1eaf70c257e ("libext2fs: translate internal ext4 acl to Posix ACL in ext2fs_xattr_[sg]et()")
Origin: upstream, https://github.com/tytso/e2fsprogs/commit/0111bdb70a9c460052387111414a2e2dc8c06822
---
 misc/fuse2fs.c | 267 +------------------------------------------------
 1 file changed, 4 insertions(+), 263 deletions(-)

diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 1ec7cd22f..eeb496d1b 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -17,12 +17,6 @@
 # include <linux/fs.h>
 # include <linux/falloc.h>
 # include <linux/xattr.h>
-# ifdef HAVE_SYS_ACL_H
-#  define TRANSLATE_LINUX_ACLS
-# endif
-#endif
-#ifdef TRANSLATE_LINUX_ACLS
-# include <sys/acl.h>
 #endif
 #include <sys/ioctl.h>
 #include <unistd.h>
@@ -119,206 +113,6 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);
 int journal_enable_debug = -1;
 #endif
 
-/* ACL translation stuff */
-#ifdef TRANSLATE_LINUX_ACLS
-/*
- * Copied from acl_ea.h in libacl source; ACLs have to be sent to and from fuse
- * in this format... at least on Linux.
- */
-#define ACL_EA_ACCESS		"system.posix_acl_access"
-#define ACL_EA_DEFAULT		"system.posix_acl_default"
-
-#define ACL_EA_VERSION		0x0002
-
-typedef struct {
-	u_int16_t	e_tag;
-	u_int16_t	e_perm;
-	u_int32_t	e_id;
-} acl_ea_entry;
-
-typedef struct {
-	u_int32_t	a_version;
-#if __GNUC_PREREQ (4, 8)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-	acl_ea_entry	a_entries[0];
-#if __GNUC_PREREQ (4, 8)
-#pragma GCC diagnostic pop
-#endif
-} acl_ea_header;
-
-static inline size_t acl_ea_size(int count)
-{
-	return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry);
-}
-
-static inline int acl_ea_count(size_t size)
-{
-	if (size < sizeof(acl_ea_header))
-		return -1;
-	size -= sizeof(acl_ea_header);
-	if (size % sizeof(acl_ea_entry))
-		return -1;
-	return size / sizeof(acl_ea_entry);
-}
-
-/*
- * ext4 ACL structures, copied from fs/ext4/acl.h.
- */
-#define EXT4_ACL_VERSION	0x0001
-
-typedef struct {
-	__u16		e_tag;
-	__u16		e_perm;
-	__u32		e_id;
-} ext4_acl_entry;
-
-typedef struct {
-	__u16		e_tag;
-	__u16		e_perm;
-} ext4_acl_entry_short;
-
-typedef struct {
-	__u32		a_version;
-} ext4_acl_header;
-
-static inline size_t ext4_acl_size(int count)
-{
-	if (count <= 4) {
-		return sizeof(ext4_acl_header) +
-		       count * sizeof(ext4_acl_entry_short);
-	} else {
-		return sizeof(ext4_acl_header) +
-		       4 * sizeof(ext4_acl_entry_short) +
-		       (count - 4) * sizeof(ext4_acl_entry);
-	}
-}
-
-static inline int ext4_acl_count(size_t size)
-{
-	ssize_t s;
-
-	size -= sizeof(ext4_acl_header);
-	s = size - 4 * sizeof(ext4_acl_entry_short);
-	if (s < 0) {
-		if (size % sizeof(ext4_acl_entry_short))
-			return -1;
-		return size / sizeof(ext4_acl_entry_short);
-	}
-	if (s % sizeof(ext4_acl_entry))
-		return -1;
-	return s / sizeof(ext4_acl_entry) + 4;
-}
-
-static errcode_t fuse_to_ext4_acl(acl_ea_header *facl, size_t facl_sz,
-				  ext4_acl_header **eacl, size_t *eacl_sz)
-{
-	int i, facl_count;
-	ext4_acl_header *h;
-	size_t h_sz;
-	ext4_acl_entry *e;
-	acl_ea_entry *a;
-	unsigned char *hptr;
-	errcode_t err;
-
-	facl_count = acl_ea_count(facl_sz);
-	h_sz = ext4_acl_size(facl_count);
-	if (facl_count < 0 || facl->a_version != ACL_EA_VERSION)
-		return EXT2_ET_INVALID_ARGUMENT;
-
-	err = ext2fs_get_mem(h_sz, &h);
-	if (err)
-		return err;
-
-	h->a_version = ext2fs_cpu_to_le32(EXT4_ACL_VERSION);
-	hptr = (unsigned char *) (h + 1);
-	for (i = 0, a = facl->a_entries; i < facl_count; i++, a++) {
-		e = (ext4_acl_entry *) hptr;
-		e->e_tag = ext2fs_cpu_to_le16(a->e_tag);
-		e->e_perm = ext2fs_cpu_to_le16(a->e_perm);
-
-		switch (a->e_tag) {
-		case ACL_USER:
-		case ACL_GROUP:
-			e->e_id = ext2fs_cpu_to_le32(a->e_id);
-			hptr += sizeof(ext4_acl_entry);
-			break;
-		case ACL_USER_OBJ:
-		case ACL_GROUP_OBJ:
-		case ACL_MASK:
-		case ACL_OTHER:
-			hptr += sizeof(ext4_acl_entry_short);
-			break;
-		default:
-			err = EXT2_ET_INVALID_ARGUMENT;
-			goto out;
-		}
-	}
-
-	*eacl = h;
-	*eacl_sz = h_sz;
-	return err;
-out:
-	ext2fs_free_mem(&h);
-	return err;
-}
-
-static errcode_t ext4_to_fuse_acl(acl_ea_header **facl, size_t *facl_sz,
-				  ext4_acl_header *eacl, size_t eacl_sz)
-{
-	int i, eacl_count;
-	acl_ea_header *f;
-	ext4_acl_entry *e;
-	acl_ea_entry *a;
-	size_t f_sz;
-	unsigned char *hptr;
-	errcode_t err;
-
-	eacl_count = ext4_acl_count(eacl_sz);
-	f_sz = acl_ea_size(eacl_count);
-	if (eacl_count < 0 ||
-	    eacl->a_version != ext2fs_cpu_to_le32(EXT4_ACL_VERSION))
-		return EXT2_ET_INVALID_ARGUMENT;
-
-	err = ext2fs_get_mem(f_sz, &f);
-	if (err)
-		return err;
-
-	f->a_version = ACL_EA_VERSION;
-	hptr = (unsigned char *) (eacl + 1);
-	for (i = 0, a = f->a_entries; i < eacl_count; i++, a++) {
-		e = (ext4_acl_entry *) hptr;
-		a->e_tag = ext2fs_le16_to_cpu(e->e_tag);
-		a->e_perm = ext2fs_le16_to_cpu(e->e_perm);
-
-		switch (a->e_tag) {
-		case ACL_USER:
-		case ACL_GROUP:
-			a->e_id = ext2fs_le32_to_cpu(e->e_id);
-			hptr += sizeof(ext4_acl_entry);
-			break;
-		case ACL_USER_OBJ:
-		case ACL_GROUP_OBJ:
-		case ACL_MASK:
-		case ACL_OTHER:
-			hptr += sizeof(ext4_acl_entry_short);
-			break;
-		default:
-			err = EXT2_ET_INVALID_ARGUMENT;
-			goto out;
-		}
-	}
-
-	*facl = f;
-	*facl_sz = f_sz;
-	return err;
-out:
-	ext2fs_free_mem(&f);
-	return err;
-}
-#endif /* TRANSLATE_LINUX_ACLS */
-
 /*
  * ext2_file_t contains a struct inode, so we can't leave files open.
  * Use this as a proxy instead.
@@ -2432,30 +2226,6 @@ static int op_statfs(const char *path EXT2FS_ATTR((unused)),
 	return 0;
 }
 
-typedef errcode_t (*xattr_xlate_get)(void **cooked_buf, size_t *cooked_sz,
-				     const void *raw_buf, size_t raw_sz);
-typedef errcode_t (*xattr_xlate_set)(const void *cooked_buf, size_t cooked_sz,
-				     const void **raw_buf, size_t *raw_sz);
-struct xattr_translate {
-	const char *prefix;
-	xattr_xlate_get get;
-	xattr_xlate_set set;
-};
-
-#define XATTR_TRANSLATOR(p, g, s) \
-	{.prefix = (p), \
-	 .get = (xattr_xlate_get)(g), \
-	 .set = (xattr_xlate_set)(s)}
-
-static struct xattr_translate xattr_translators[] = {
-#ifdef TRANSLATE_LINUX_ACLS
-	XATTR_TRANSLATOR(ACL_EA_ACCESS, ext4_to_fuse_acl, fuse_to_ext4_acl),
-	XATTR_TRANSLATOR(ACL_EA_DEFAULT, ext4_to_fuse_acl, fuse_to_ext4_acl),
-#endif
-	XATTR_TRANSLATOR(NULL, NULL, NULL),
-};
-#undef XATTR_TRANSLATOR
-
 static int op_getxattr(const char *path, const char *key, char *value,
 		       size_t len)
 {
@@ -2463,9 +2233,8 @@ static int op_getxattr(const char *path, const char *key, char *value,
 	struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
 	ext2_filsys fs;
 	struct ext2_xattr_handle *h;
-	struct xattr_translate *xt;
-	void *ptr, *cptr;
-	size_t plen, clen;
+	void *ptr;
+	size_t plen;
 	ext2_ino_t ino;
 	errcode_t err;
 	int ret = 0;
@@ -2507,17 +2276,6 @@ static int op_getxattr(const char *path, const char *key, char *value,
 		goto out2;
 	}
 
-	for (xt = xattr_translators; xt->prefix != NULL; xt++) {
-		if (strncmp(key, xt->prefix, strlen(xt->prefix)) == 0) {
-			err = xt->get(&cptr, &clen, ptr, plen);
-			if (err)
-				goto out3;
-			ext2fs_free_mem(&ptr);
-			ptr = cptr;
-			plen = clen;
-		}
-	}
-
 	if (!len) {
 		ret = plen;
 	} else if (len < plen) {
@@ -2527,7 +2285,6 @@ static int op_getxattr(const char *path, const char *key, char *value,
 		ret = plen;
 	}
 
-out3:
 	ext2fs_free_mem(&ptr);
 out2:
 	err = ext2fs_xattrs_close(&h);
@@ -2645,9 +2402,6 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)),
 	struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
 	ext2_filsys fs;
 	struct ext2_xattr_handle *h;
-	struct xattr_translate *xt;
-	const void *cvalue;
-	size_t clen;
 	ext2_ino_t ino;
 	errcode_t err;
 	int ret = 0;
@@ -2686,26 +2440,13 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)),
 		goto out2;
 	}
 
-	cvalue = value;
-	clen = len;
-	for (xt = xattr_translators; xt->prefix != NULL; xt++) {
-		if (strncmp(key, xt->prefix, strlen(xt->prefix)) == 0) {
-			err = xt->set(value, len, &cvalue, &clen);
-			if (err)
-				goto out3;
-		}
-	}
-
-	err = ext2fs_xattr_set(h, key, cvalue, clen);
+	err = ext2fs_xattr_set(h, key, value, len);
 	if (err) {
 		ret = translate_error(fs, ino, err);
-		goto out3;
+		goto out2;
 	}
 
 	ret = update_ctime(fs, ino, NULL);
-out3:
-	if (cvalue != value)
-		ext2fs_free_mem(&cvalue);
 out2:
 	err = ext2fs_xattrs_close(&h);
 	if (!ret && err)
-- 
2.47.2