X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftmpfiles%2Ftmpfiles.c;h=389f4931937d1a2342cb91c857b8d2acec08180c;hp=3c8993e8942f7b6736cac91d9a958021621941bc;hb=7fcb4b9b17fcb19c97fdfff689dc0aaaa1391b68;hpb=50d9e46dbb8400d4570781728c63b151d9ca982b diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 3c8993e89..389f49319 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -329,8 +329,7 @@ static int dir_cleanup( usec_t age; _cleanup_free_ char *sub_path = NULL; - if (streq(dent->d_name, ".") || - streq(dent->d_name, "..")) + if (STR_IN_SET(dent->d_name, ".", "..")) continue; if (fstatat(dirfd(d), dent->d_name, &s, AT_SYMLINK_NOFOLLOW) < 0) { @@ -614,22 +613,35 @@ static int get_acls_from_arg(Item *item) { } static int path_set_acl(const char *path, acl_type_t type, acl_t acl, bool modify) { - _cleanup_(acl_freep) acl_t cleanme = NULL; + _cleanup_(acl_freep) acl_t dup = NULL; int r; if (modify) { - r = acls_for_file(path, type, acl, &cleanme); + r = acls_for_file(path, type, acl, &dup); if (r < 0) return r; - acl = cleanme; - }; - r = acl_set_file(path, type, acl); + r = calc_acl_mask_if_needed(&dup); + if (r < 0) + return r; + } else { + dup = acl_dup(acl); + if (!dup) + return -errno; + + /* the mask was already added earlier if needed */ + } + + r = add_base_acls_if_needed(&dup, path); + if (r < 0) + return r; + + r = acl_set_file(path, type, dup); if (r < 0) { _cleanup_(acl_free_charpp) char *t; r = -errno; - t = acl_to_any_text(acl, NULL, ',', TEXT_ABBREVIATE); + t = acl_to_any_text(dup, NULL, ',', TEXT_ABBREVIATE); log_error_errno(r, "Setting %s ACL \"%s\" on %s failed: %m", type == ACL_TYPE_ACCESS ? "access" : "default", @@ -752,7 +764,7 @@ static int item_do_children(Item *i, const char *path, action_t action) { break; } - if (streq(de->d_name, ".") || streq(de->d_name, "..")) + if (STR_IN_SET(de->d_name, ".", "..")) continue; p = strjoin(path, "/", de->d_name, NULL); @@ -1071,27 +1083,6 @@ static int remove_item_instance(Item *i, const char *instance) { switch (i->type) { - case CREATE_FILE: - case TRUNCATE_FILE: - case CREATE_DIRECTORY: - case CREATE_SUBVOLUME: - case CREATE_FIFO: - case CREATE_SYMLINK: - case CREATE_BLOCK_DEVICE: - case CREATE_CHAR_DEVICE: - case IGNORE_PATH: - case IGNORE_DIRECTORY_PATH: - case ADJUST_MODE: - case RELABEL_PATH: - case RECURSIVE_RELABEL_PATH: - case WRITE_FILE: - case COPY_FILES: - case SET_XATTR: - case RECURSIVE_SET_XATTR: - case SET_ACL: - case RECURSIVE_SET_ACL: - break; - case REMOVE_PATH: if (remove(instance) < 0 && errno != ENOENT) return log_error_errno(errno, "rm(%s): %m", instance); @@ -1107,6 +1098,9 @@ static int remove_item_instance(Item *i, const char *instance) { return log_error_errno(r, "rm_rf(%s): %m", instance); break; + + default: + assert_not_reached("wut?"); } return 0;