1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <errno.h>
5 #include <unistd.h>
6 
7 #if HAVE_ACL
8 #include <acl/libacl.h>
9 #include <stdbool.h>
10 #include <sys/acl.h>
11 
12 #include "macro.h"
13 
14 int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
15 int calc_acl_mask_if_needed(acl_t *acl_p);
16 int add_base_acls_if_needed(acl_t *acl_p, const char *path);
17 int acl_search_groups(const char* path, char ***ret_groups);
18 int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask);
19 int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl);
20 int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask);
21 
22 /* acl_free takes multiple argument types.
23  * Multiple cleanup functions are necessary. */
24 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(acl_t, acl_free, NULL);
25 #define acl_free_charp acl_free
26 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, acl_free_charp, NULL);
27 #define acl_free_uid_tp acl_free
28 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(uid_t*, acl_free_uid_tp, NULL);
29 #define acl_free_gid_tp acl_free
30 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gid_t*, acl_free_gid_tp, NULL);
31 
32 #else
33 #define ACL_READ    0x04
34 #define ACL_WRITE   0x02
35 #define ACL_EXECUTE 0x01
36 
fd_add_uid_acl_permission(int fd,uid_t uid,unsigned mask)37 static inline int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask) {
38         return -EOPNOTSUPP;
39 }
40 #endif
41