diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch b/meta/recipes-core/systemd/systemd/0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch deleted file mode 100644 index 6652e28e23..0000000000 --- a/meta/recipes-core/systemd/systemd/0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | Upstream-Status: Backport | ||
2 | Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca> | ||
3 | |||
4 | From 33d36e28b0a23fb7ac33435a1329d65bff1ba4ec Mon Sep 17 00:00:00 2001 | ||
5 | From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl> | ||
6 | Date: Mon, 23 Feb 2015 23:19:54 -0500 | ||
7 | Subject: [PATCH] tmpfiles: avoid creating duplicate acl entries | ||
8 | |||
9 | https://bugs.freedesktop.org/show_bug.cgi?id=89202 | ||
10 | https://bugs.debian.org/778656 | ||
11 | |||
12 | Status quo ante can be restored with: | ||
13 | getfacl -p /var/log/journal/`cat /etc/machine-id`|grep -v '^#'|sort -u|sudo setfacl --set-file=- /var/log/journal/`cat /etc/machine-id` | ||
14 | |||
15 | (cherry picked from commit 1c73f3bc29111a00738569c9d40a989b161a0624) | ||
16 | --- | ||
17 | src/shared/acl-util.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++-- | ||
18 | src/shared/acl-util.h | 4 +++ | ||
19 | 2 files changed, 81 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c | ||
22 | index a4ff1ab..cbe09d7 100644 | ||
23 | --- a/src/shared/acl-util.c | ||
24 | +++ b/src/shared/acl-util.c | ||
25 | @@ -282,6 +282,77 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | +static int acl_entry_equal(acl_entry_t a, acl_entry_t b) { | ||
30 | + acl_tag_t tag_a, tag_b; | ||
31 | + | ||
32 | + if (acl_get_tag_type(a, &tag_a) < 0) | ||
33 | + return -errno; | ||
34 | + | ||
35 | + if (acl_get_tag_type(b, &tag_b) < 0) | ||
36 | + return -errno; | ||
37 | + | ||
38 | + if (tag_a != tag_b) | ||
39 | + return false; | ||
40 | + | ||
41 | + switch (tag_a) { | ||
42 | + case ACL_USER_OBJ: | ||
43 | + case ACL_GROUP_OBJ: | ||
44 | + case ACL_MASK: | ||
45 | + case ACL_OTHER: | ||
46 | + /* can have only one of those */ | ||
47 | + return true; | ||
48 | + case ACL_USER: { | ||
49 | + _cleanup_(acl_free_uid_tpp) uid_t *uid_a, *uid_b; | ||
50 | + | ||
51 | + uid_a = acl_get_qualifier(a); | ||
52 | + if (!uid_a) | ||
53 | + return -errno; | ||
54 | + | ||
55 | + uid_b = acl_get_qualifier(b); | ||
56 | + if (!uid_b) | ||
57 | + return -errno; | ||
58 | + | ||
59 | + return *uid_a == *uid_b; | ||
60 | + } | ||
61 | + case ACL_GROUP: { | ||
62 | + _cleanup_(acl_free_gid_tpp) gid_t *gid_a, *gid_b; | ||
63 | + | ||
64 | + gid_a = acl_get_qualifier(a); | ||
65 | + if (!gid_a) | ||
66 | + return -errno; | ||
67 | + | ||
68 | + gid_b = acl_get_qualifier(b); | ||
69 | + if (!gid_b) | ||
70 | + return -errno; | ||
71 | + | ||
72 | + return *gid_a == *gid_b; | ||
73 | + } | ||
74 | + default: | ||
75 | + assert_not_reached("Unknown acl tag type"); | ||
76 | + } | ||
77 | +} | ||
78 | + | ||
79 | +static int find_acl_entry(acl_t acl, acl_entry_t entry, acl_entry_t *out) { | ||
80 | + acl_entry_t i; | ||
81 | + int r; | ||
82 | + | ||
83 | + for (r = acl_get_entry(acl, ACL_FIRST_ENTRY, &i); | ||
84 | + r > 0; | ||
85 | + r = acl_get_entry(acl, ACL_NEXT_ENTRY, &i)) { | ||
86 | + | ||
87 | + r = acl_entry_equal(i, entry); | ||
88 | + if (r < 0) | ||
89 | + return r; | ||
90 | + if (r > 0) { | ||
91 | + *out = i; | ||
92 | + return 1; | ||
93 | + } | ||
94 | + } | ||
95 | + if (r < 0) | ||
96 | + return -errno; | ||
97 | + return 0; | ||
98 | +} | ||
99 | + | ||
100 | int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl) { | ||
101 | _cleanup_(acl_freep) acl_t old; | ||
102 | acl_entry_t i; | ||
103 | @@ -297,8 +368,12 @@ int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl) { | ||
104 | |||
105 | acl_entry_t j; | ||
106 | |||
107 | - if (acl_create_entry(&old, &j) < 0) | ||
108 | - return -errno; | ||
109 | + r = find_acl_entry(old, i, &j); | ||
110 | + if (r < 0) | ||
111 | + return r; | ||
112 | + if (r == 0) | ||
113 | + if (acl_create_entry(&old, &j) < 0) | ||
114 | + return -errno; | ||
115 | |||
116 | if (acl_copy_entry(j, i) < 0) | ||
117 | return -errno; | ||
118 | diff --git a/src/shared/acl-util.h b/src/shared/acl-util.h | ||
119 | index 90e88ff..fdb9006 100644 | ||
120 | --- a/src/shared/acl-util.h | ||
121 | +++ b/src/shared/acl-util.h | ||
122 | @@ -41,5 +41,9 @@ int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl); | ||
123 | DEFINE_TRIVIAL_CLEANUP_FUNC(acl_t, acl_free); | ||
124 | #define acl_free_charp acl_free | ||
125 | DEFINE_TRIVIAL_CLEANUP_FUNC(char*, acl_free_charp); | ||
126 | +#define acl_free_uid_tp acl_free | ||
127 | +DEFINE_TRIVIAL_CLEANUP_FUNC(uid_t*, acl_free_uid_tp); | ||
128 | +#define acl_free_gid_tp acl_free | ||
129 | +DEFINE_TRIVIAL_CLEANUP_FUNC(gid_t*, acl_free_gid_tp); | ||
130 | |||
131 | #endif | ||
132 | -- | ||
133 | 2.3.1 | ||
134 | |||