diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2015-06-17 23:10:19 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2015-06-17 23:10:19 +0200 |
commit | 921ee38ff6222d9716da877639b2a0e9195c3a60 (patch) | |
tree | 7838fc65a7a329a4181b6588d2a92e18eb8f20d8 | |
parent | de587378ea5d22e11373b18b4fcabf8f26f89529 (diff) | |
parent | e738c945ec16e14b96eab402024b0caca47f89d8 (diff) |
Merge pull request #275 from poettering/acl-fixes
acl-util: various smaller fixes to parse_acl()
-rw-r--r-- | src/shared/acl-util.c | 13 | ||||
-rw-r--r-- | src/shared/acl-util.h | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c index 466f9aa601..bd8c988751 100644 --- a/src/shared/acl-util.c +++ b/src/shared/acl-util.c @@ -223,7 +223,7 @@ int acl_search_groups(const char *path, char ***ret_groups) { return ret; } -int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) { +int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) { _cleanup_free_ char **a = NULL, **d = NULL; /* strings are not be freed */ _cleanup_strv_free_ char **split; char **entry; @@ -232,7 +232,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) split = strv_split(text, ","); if (!split) - return log_oom(); + return -ENOMEM; STRV_FOREACH(entry, split) { char *p; @@ -245,9 +245,9 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) r = strv_push(&d, p); else r = strv_push(&a, *entry); + if (r < 0) + return r; } - if (r < 0) - return r; if (!strv_isempty(a)) { _cleanup_free_ char *join; @@ -258,7 +258,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) a_acl = acl_from_text(join); if (!a_acl) - return -EINVAL; + return -errno; if (want_mask) { r = calc_acl_mask_if_needed(&a_acl); @@ -276,7 +276,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) d_acl = acl_from_text(join); if (!d_acl) - return -EINVAL; + return -errno; if (want_mask) { r = calc_acl_mask_if_needed(&d_acl); @@ -288,6 +288,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) *acl_access = a_acl; *acl_default = d_acl; a_acl = d_acl = NULL; + return 0; } diff --git a/src/shared/acl-util.h b/src/shared/acl-util.h index c8bcc266d0..cf612e8722 100644 --- a/src/shared/acl-util.h +++ b/src/shared/acl-util.h @@ -33,7 +33,7 @@ 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 add_base_acls_if_needed(acl_t *acl_p, const char *path); int acl_search_groups(const char* path, char ***ret_groups); -int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask); +int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask); int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl); /* acl_free takes multiple argument types. |