summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2013-05-28 20:45:34 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-05-30 00:43:39 -0400
commit23ad4dd8844c582929115a11ed2830a1371568d6 (patch)
tree72da26672d1661c56b8ac5e2735167682692d952 /src/shared
parent8de1fd281e82c038797b02a447056a382f9b5110 (diff)
journald: DO recalculate the ACL mask, but only if it doesn't exist
Since 11ec7ce, journald isn't setting the ACLs properly anymore if the files had no ACLs to begin with: acl_set_fd fails with EINVAL. An ACL with ACL_USER or ACL_GROUP entries but no ACL_MASK entry is invalid, so make sure a mask exists before trying to set the ACL.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/acl-util.c28
-rw-r--r--src/shared/acl-util.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c
index 48bb12f46b..fb04e49dc4 100644
--- a/src/shared/acl-util.c
+++ b/src/shared/acl-util.c
@@ -69,6 +69,34 @@ int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry) {
return 0;
}
+int calc_acl_mask_if_needed(acl_t *acl_p) {
+ acl_entry_t i;
+ int found;
+
+ assert(acl_p);
+
+ for (found = acl_get_entry(*acl_p, ACL_FIRST_ENTRY, &i);
+ found > 0;
+ found = acl_get_entry(*acl_p, ACL_NEXT_ENTRY, &i)) {
+
+ acl_tag_t tag;
+
+ if (acl_get_tag_type(i, &tag) < 0)
+ return -errno;
+
+ if (tag == ACL_MASK)
+ return 0;
+ }
+
+ if (found < 0)
+ return -errno;
+
+ if (acl_calc_mask(acl_p) < 0)
+ return -errno;
+
+ return 0;
+}
+
int search_acl_groups(char*** dst, const char* path, bool* belong) {
acl_t acl;
diff --git a/src/shared/acl-util.h b/src/shared/acl-util.h
index 23090d9984..36ef490d7e 100644
--- a/src/shared/acl-util.h
+++ b/src/shared/acl-util.h
@@ -24,4 +24,5 @@
#include <stdbool.h>
int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
+int calc_acl_mask_if_needed(acl_t *acl_p);
int search_acl_groups(char*** dst, const char* path, bool* belong);