chiark / gitweb /
Prep v228: Apply more cosmetic changes found in upstream.
[elogind.git] / src / shared / acl-util.c
index 466f9aa601590d36a422f334da20051f99171354..f6e19dcb2ab64d988ac07ab76e036eb7eda186cc 100644 (file)
 #include <stdbool.h>
 
 #include "acl-util.h"
-#include "util.h"
+#include "alloc-util.h"
+#include "string-util.h"
 #include "strv.h"
+#include "user-util.h"
+#include "util.h"
 
 int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry) {
         acl_entry_t i;
@@ -65,6 +68,8 @@ int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int calc_acl_mask_if_needed(acl_t *acl_p) {
         acl_entry_t i;
         int r;
@@ -223,7 +228,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 +237,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 +250,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 +263,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 +281,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 +293,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;
 }
 
@@ -394,3 +400,4 @@ int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl) {
         old = NULL;
         return 0;
 }
+#endif // 0