2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2012-07-18 19:07:51 +02:00
|
|
|
#pragma once
|
2011-10-07 23:03:07 +02:00
|
|
|
|
2020-08-26 10:59:32 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
2015-01-18 05:27:39 +01:00
|
|
|
|
2020-08-26 10:59:32 +02:00
|
|
|
#if HAVE_ACL
|
2015-11-18 22:46:33 +01:00
|
|
|
#include <acl/libacl.h>
|
2013-03-22 15:35:26 +01:00
|
|
|
#include <stdbool.h>
|
2015-01-18 05:27:39 +01:00
|
|
|
#include <sys/acl.h>
|
|
|
|
|
|
|
|
#include "macro.h"
|
2013-03-22 15:35:26 +01:00
|
|
|
|
2011-10-07 23:03:07 +02:00
|
|
|
int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
|
2013-05-28 20:45:34 +02:00
|
|
|
int calc_acl_mask_if_needed(acl_t *acl_p);
|
2015-01-19 00:22:27 +01:00
|
|
|
int add_base_acls_if_needed(acl_t *acl_p, const char *path);
|
2015-04-22 22:54:23 +02:00
|
|
|
int acl_search_groups(const char* path, char ***ret_groups);
|
2015-06-17 22:08:21 +02:00
|
|
|
int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask);
|
2015-01-18 11:02:47 +01:00
|
|
|
int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl);
|
2020-08-26 10:59:32 +02:00
|
|
|
int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask);
|
2014-06-18 22:02:18 +02:00
|
|
|
|
2015-01-18 05:27:39 +01:00
|
|
|
/* acl_free takes multiple argument types.
|
|
|
|
* Multiple cleanup functions are necessary. */
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(acl_t, acl_free);
|
|
|
|
#define acl_free_charp acl_free
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, acl_free_charp);
|
2015-02-24 05:19:54 +01:00
|
|
|
#define acl_free_uid_tp acl_free
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(uid_t*, acl_free_uid_tp);
|
|
|
|
#define acl_free_gid_tp acl_free
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(gid_t*, acl_free_gid_tp);
|
2014-06-18 22:02:18 +02:00
|
|
|
|
2020-08-26 10:59:32 +02:00
|
|
|
#else
|
|
|
|
#define ACL_READ 0x04
|
|
|
|
#define ACL_WRITE 0x02
|
|
|
|
#define ACL_EXECUTE 0x01
|
|
|
|
|
|
|
|
static inline int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask) {
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2015-01-18 05:27:39 +01:00
|
|
|
#endif
|