]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ | |
2 | #pragma once | |
3 | ||
4 | #include "forward.h" | |
5 | ||
6 | int fd_acl_make_read_only_fallback(int fd); | |
7 | int fd_acl_make_writable_fallback(int fd); | |
8 | ||
9 | #if HAVE_ACL | |
10 | #include <acl/libacl.h> /* IWYU pragma: export */ | |
11 | #include <sys/acl.h> /* IWYU pragma: export */ | |
12 | ||
13 | int calc_acl_mask_if_needed(acl_t *acl_p); | |
14 | int add_base_acls_if_needed(acl_t *acl_p, const char *path); | |
15 | int acl_search_groups(const char* path, char ***ret_groups); | |
16 | int parse_acl( | |
17 | const char *text, | |
18 | acl_t *ret_acl_access, | |
19 | acl_t *ret_acl_access_exec, | |
20 | acl_t *ret_acl_default, | |
21 | bool want_mask); | |
22 | int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *ret); | |
23 | int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask); | |
24 | ||
25 | int fd_acl_make_read_only(int fd); | |
26 | int fd_acl_make_writable(int fd); | |
27 | ||
28 | /* acl_free takes multiple argument types. | |
29 | * Multiple cleanup functions are necessary. */ | |
30 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(acl_t, acl_free, NULL); | |
31 | #define acl_free_charp acl_free | |
32 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, acl_free_charp, NULL); | |
33 | #define acl_free_uid_tp acl_free | |
34 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(uid_t*, acl_free_uid_tp, NULL); | |
35 | #define acl_free_gid_tp acl_free | |
36 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gid_t*, acl_free_gid_tp, NULL); | |
37 | ||
38 | #else | |
39 | #define ACL_READ 0x04 | |
40 | #define ACL_WRITE 0x02 | |
41 | #define ACL_EXECUTE 0x01 | |
42 | ||
43 | static inline int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask) { | |
44 | return -EOPNOTSUPP; | |
45 | } | |
46 | ||
47 | static inline int fd_acl_make_read_only(int fd) { | |
48 | return fd_acl_make_read_only_fallback(fd); | |
49 | } | |
50 | ||
51 | static inline int fd_acl_make_writable(int fd) { | |
52 | return fd_acl_make_writable_fallback(fd); | |
53 | } | |
54 | ||
55 | #endif |