forked from arkhipov/acl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacl.h
72 lines (60 loc) · 2.14 KB
/
acl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* -------------------------------------------------------------------------
*
* acl.h
*
* Copyright (c) 2015-2016 Vladislav Arkhipov <vlad@arkhipov.ru>
*
* -------------------------------------------------------------------------
*/
#ifndef __ACL_H__
#define __ACL_H__
#include "lib/stringinfo.h"
#include "utils/array.h"
/* ACE types */
#define ACE_ACCESS_ALLOWED 0x00000001
#define ACE_ACCESS_DENIED 0x00000002
/* ACE flags
* 0-15 application-specific
* 16-31 reserved */
#define ACE_INHERIT_ONLY 0x80000000
#define ACE_OBJECT_INHERIT 0x40000000
#define ACE_CONTAINER_INHERIT 0x20000000
#define ACE_NO_PROPAGATE_INHERIT 0x10000000
#define ACE_INHERITED 0x08000000
#define ACE_INVALID 0x04000000
#define ACE_FLAGS_APPLICATION_SPECIFIC 0x0000FFFF
/* ACE access rights
* 0-15 application-specific
* 16-31 reserved */
#define ACE_READ 0x80000000
#define ACE_WRITE 0x40000000
#define ACE_DELETE 0x20000000
#define ACE_READ_ACL 0x10000000
#define ACE_WRITE_ACL 0x08000000
typedef struct AclEntryBase {
uint32 type;
uint32 flags;
uint32 mask;
} AclEntryBase;
void parse_acl_entry(const char *s, AclEntryBase *acl_entry_base,
void *opaque,
const char *parse_who(const char *s, void *opaque));
void format_acl_entry(StringInfo out, intptr_t opaque,
AclEntryBase *acl_entry_base,
void (*format_who)(StringInfo out, intptr_t opaque));
uint32 check_access(const ArrayType *acl, int16 typlen, char typalign,
AclEntryBase * (*extract_acl_entry_base)(void *acl_entry),
uint32 mask, intptr_t who,
bool (*who_matches)(void *acl_entry, intptr_t who),
bool implicit_allow);
text *check_access_text_mask(const ArrayType *acl, int16 typlen,
char typalign,
AclEntryBase * (*extract_acl_entry_base)(void *acl_entry),
text *text_mask, intptr_t who,
bool (*who_matches)(void *acl_entry, intptr_t who),
bool implicit_allow);
ArrayType *merge_acls(const ArrayType *parent_acl, const ArrayType *acl,
int16 typlem, char typalign,
AclEntryBase * (*extract_acl_entry_base)(void *acl_entry),
bool container, bool deny_first);
#endif