diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2015-03-04 10:22:00 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-10 10:47:47 +0000 |
commit | d6a2a54e5b20b219ed252dce30784289125e1f39 (patch) | |
tree | 9301cb8c8b0755104174ed45a8b45943957c0bc4 /meta | |
parent | f5e4349011bd00aa47d142022dcdd1d1706a9655 (diff) | |
download | poky-d6a2a54e5b20b219ed252dce30784289125e1f39.tar.gz |
systemd: fix systemd-tmpfiles ACL issues
On systems where /var/log is not a volatile systemd-tmpfiles creates
duplicate ACL entries. This causes systemd-tmpfiles service to fail.
Also quietly ignore ACL settings on filesystems that don't support ACLs.
Backport the fixes from systemd master to fix these issues.
(From OE-Core rev: 73a045a1b52d8260d60517bbb5d4c74132d03b10)
Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
3 files changed, 222 insertions, 0 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 new file mode 100644 index 0000000000..6652e28e23 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch | |||
@@ -0,0 +1,134 @@ | |||
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 | |||
diff --git a/meta/recipes-core/systemd/systemd/0002-tmpfiles-quietly-ignore-ACLs-on-unsupported-filesyst.patch b/meta/recipes-core/systemd/systemd/0002-tmpfiles-quietly-ignore-ACLs-on-unsupported-filesyst.patch new file mode 100644 index 0000000000..c195437ba0 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0002-tmpfiles-quietly-ignore-ACLs-on-unsupported-filesyst.patch | |||
@@ -0,0 +1,86 @@ | |||
1 | Upstream-Status: Backport | ||
2 | Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca> | ||
3 | |||
4 | From 31d05181e3a34c5c0ff6314d8eca1c3b4bb29423 Mon Sep 17 00:00:00 2001 | ||
5 | From: Hans-Peter Deifel <hpd@hpdeifel.de> | ||
6 | Date: Tue, 3 Mar 2015 00:35:08 +0100 | ||
7 | Subject: [PATCH 2/2] tmpfiles: quietly ignore ACLs on unsupported filesystems | ||
8 | |||
9 | A warning is printed if ACLs cannot be retrieved for any reason other | ||
10 | than -ENOSYS. For -ENOSYS, debug log is printed. | ||
11 | |||
12 | (cherry picked from commit d873e8778c92014c02a9122852758b436fa95c0e) | ||
13 | --- | ||
14 | src/tmpfiles/tmpfiles.c | 36 ++++++++++++++++++++---------------- | ||
15 | 1 file changed, 20 insertions(+), 16 deletions(-) | ||
16 | |||
17 | diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c | ||
18 | index 88ba7e4..187997e 100644 | ||
19 | --- a/src/tmpfiles/tmpfiles.c | ||
20 | +++ b/src/tmpfiles/tmpfiles.c | ||
21 | @@ -704,6 +704,9 @@ static int path_set_acl(const char *path, acl_type_t type, acl_t acl, bool modif | ||
22 | int r; | ||
23 | _cleanup_(acl_free_charpp) char *t = NULL; | ||
24 | |||
25 | + /* Returns 0 for success, positive error if already warned, | ||
26 | + * negative error otherwise. */ | ||
27 | + | ||
28 | if (modify) { | ||
29 | r = acls_for_file(path, type, acl, &dup); | ||
30 | if (r < 0) | ||
31 | @@ -731,35 +734,36 @@ static int path_set_acl(const char *path, acl_type_t type, acl_t acl, bool modif | ||
32 | |||
33 | r = acl_set_file(path, type, dup); | ||
34 | if (r < 0) | ||
35 | - return log_error_errno(-errno, | ||
36 | - "Setting %s ACL \"%s\" on %s failed: %m", | ||
37 | - type == ACL_TYPE_ACCESS ? "access" : "default", | ||
38 | - strna(t), path); | ||
39 | + return -log_error_errno(errno, | ||
40 | + "Setting %s ACL \"%s\" on %s failed: %m", | ||
41 | + type == ACL_TYPE_ACCESS ? "access" : "default", | ||
42 | + strna(t), path); | ||
43 | + | ||
44 | return 0; | ||
45 | } | ||
46 | #endif | ||
47 | |||
48 | static int path_set_acls(Item *item, const char *path) { | ||
49 | + int r = 0; | ||
50 | #ifdef HAVE_ACL | ||
51 | - int r; | ||
52 | - | ||
53 | assert(item); | ||
54 | assert(path); | ||
55 | |||
56 | - if (item->acl_access) { | ||
57 | + if (item->acl_access) | ||
58 | r = path_set_acl(path, ACL_TYPE_ACCESS, item->acl_access, item->force); | ||
59 | - if (r < 0) | ||
60 | - return r; | ||
61 | - } | ||
62 | |||
63 | - if (item->acl_default) { | ||
64 | + if (r == 0 && item->acl_default) | ||
65 | r = path_set_acl(path, ACL_TYPE_DEFAULT, item->acl_default, item->force); | ||
66 | - if (r < 0) | ||
67 | - return r; | ||
68 | - } | ||
69 | -#endif | ||
70 | |||
71 | - return 0; | ||
72 | + if (r > 0) | ||
73 | + return -r; /* already warned */ | ||
74 | + else if (r == -ENOTSUP) { | ||
75 | + log_debug_errno(r, "ACLs not supported by file system at %s", path); | ||
76 | + return 0; | ||
77 | + } else if (r < 0) | ||
78 | + log_error_errno(r, "ACL operation on \"%s\" failed: %m", path); | ||
79 | +#endif | ||
80 | + return r; | ||
81 | } | ||
82 | |||
83 | static int write_one_file(Item *i, const char *path) { | ||
84 | -- | ||
85 | 2.3.1 | ||
86 | |||
diff --git a/meta/recipes-core/systemd/systemd_219.bb b/meta/recipes-core/systemd/systemd_219.bb index d5c14a42c4..95b3f49148 100644 --- a/meta/recipes-core/systemd/systemd_219.bb +++ b/meta/recipes-core/systemd/systemd_219.bb | |||
@@ -40,6 +40,8 @@ SRC_URI = "git://anongit.freedesktop.org/systemd/systemd;branch=master;protocol= | |||
40 | file://0009-sysv-generator-add-support-for-executing-scripts-und.patch \ | 40 | file://0009-sysv-generator-add-support-for-executing-scripts-und.patch \ |
41 | file://0010-Make-root-s-home-directory-configurable.patch \ | 41 | file://0010-Make-root-s-home-directory-configurable.patch \ |
42 | file://0011-systemd-user-avoid-using-system-auth.patch \ | 42 | file://0011-systemd-user-avoid-using-system-auth.patch \ |
43 | file://0001-tmpfiles-avoid-creating-duplicate-acl-entries.patch \ | ||
44 | file://0002-tmpfiles-quietly-ignore-ACLs-on-unsupported-filesyst.patch \ | ||
43 | file://tmpfiles-pam.patch \ | 45 | file://tmpfiles-pam.patch \ |
44 | file://touchscreen.rules \ | 46 | file://touchscreen.rules \ |
45 | file://00-create-volatile.conf \ | 47 | file://00-create-volatile.conf \ |