|
1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
3 * |
|
4 * Copyright 2013 Olaf Wintermann. All rights reserved. |
|
5 * |
|
6 * Redistribution and use in source and binary forms, with or without |
|
7 * modification, are permitted provided that the following conditions are met: |
|
8 * |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * |
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
13 * notice, this list of conditions and the following disclaimer in the |
|
14 * documentation and/or other materials provided with the distribution. |
|
15 * |
|
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
26 * POSSIBILITY OF SUCH DAMAGE. |
|
27 */ |
|
28 |
|
29 #ifndef _CONFIG_ACL_H |
|
30 #define _CONFIG_ACL_H |
|
31 |
|
32 #include "conf.h" |
|
33 #include <inttypes.h> |
|
34 |
|
35 #ifdef __cplusplus |
|
36 extern "C" { |
|
37 #endif |
|
38 |
|
39 typedef struct _acl_conf ACLConfig; |
|
40 |
|
41 typedef struct _acl_file { |
|
42 ConfigParser parser; |
|
43 char *file; |
|
44 UcxList *namedACLs; // ACLConfig list |
|
45 UcxList *uriACLs; // ACLConfig list |
|
46 UcxList *pathACLs; // ACLConfig list |
|
47 |
|
48 // temp data |
|
49 ACLConfig *cur; |
|
50 } ACLFile; |
|
51 |
|
52 struct _acl_conf { |
|
53 sstr_t id; // name, uri or path |
|
54 sstr_t type; // webserver ACL or file system ACL |
|
55 UcxList *authparam; // authentication parameters |
|
56 UcxList *entries; // ACEConfig list |
|
57 }; |
|
58 |
|
59 typedef struct _ace_conf { |
|
60 sstr_t who; |
|
61 uint32_t access_mask; |
|
62 uint16_t flags; |
|
63 uint16_t type; |
|
64 } ACEConfig; |
|
65 |
|
66 |
|
67 /* |
|
68 * the flags are a duplicate of the webserver's acl flags |
|
69 */ |
|
70 |
|
71 /* |
|
72 * access permissions |
|
73 */ |
|
74 #define ACLCFG_READ_DATA 0x0001 |
|
75 #define ACLCFG_WRITE_DATA 0x0002 |
|
76 #define ACLCFG_APPEND 0x0002 |
|
77 #define ACLCFG_ADD_FILE 0x0004 |
|
78 #define ACLCFG_ADD_SUBDIRECTORY 0x0004 |
|
79 #define ACLCFG_READ_XATTR 0x0008 |
|
80 #define ACLCFG_WRITE_XATTR 0x0010 |
|
81 #define ACLCFG_EXECUTE 0x0020 |
|
82 #define ACLCFG_DELETE_CHILD 0x0040 |
|
83 #define ACLCFG_DELETE 0x0040 |
|
84 #define ACLCFG_READ_ATTRIBUTES 0x0080 |
|
85 #define ACLCFG_WRITE_ATTRIBUTES 0x0100 |
|
86 #define ACLCFG_LIST 0x0200 |
|
87 #define ACLCFG_READ_ACL 0x0400 |
|
88 #define ACLCFG_WRITE_ACL 0x0800 |
|
89 #define ACLCFG_WRITE_OWNER 0x1000 |
|
90 #define ACLCFG_SYNCHRONIZE 0x2000 |
|
91 |
|
92 #define ACLCFG_READ \ |
|
93 (ACLCFG_READ_DATA|ACLCFG_READ_XATTR|ACLCFG_READ_ATTRIBUTES) |
|
94 #define ACLCFG_WRITE \ |
|
95 (ACLCFG_WRITE_DATA|ACLCFG_WRITE_XATTR|ACLCFG_WRITE_ATTRIBUTES) |
|
96 |
|
97 /* |
|
98 * ace flags |
|
99 */ |
|
100 #define ACLCFG_FILE_INHERIT 0x0001 |
|
101 #define ACLCFG_DIR_INHERIT 0x0002 |
|
102 #define ACLCFG_NO_PROPAGATE 0x0004 |
|
103 #define ACLCFG_INHERIT_ONLY 0x0008 |
|
104 #define ACLCFG_SUCCESSFUL_ACCESS_FLAG 0x0010 |
|
105 #define ACLCFG_FAILED_ACCESS_ACE_FLAG 0x0020 |
|
106 #define ACLCFG_IDENTIFIER_GROUP 0x0040 |
|
107 #define ACLCFG_OWNER 0x1000 |
|
108 #define ACLCFG_GROUP 0x2000 |
|
109 #define ACLCFG_EVERYONE 0x4000 |
|
110 |
|
111 /* |
|
112 * ace type |
|
113 */ |
|
114 #define ACLCFG_TYPE_ALLOWED 0x01 |
|
115 #define ACLCFG_TYPE_DENIED 0x02 |
|
116 #define ACLCFG_TYPE_AUDIT 0x03 |
|
117 #define ACLCFG_TYPE_ALARM 0x04 |
|
118 |
|
119 |
|
120 ACLFile* load_acl_file(char *file); |
|
121 |
|
122 void free_acl_file(ACLFile *aclfile); |
|
123 |
|
124 |
|
125 int acl_parse(void *p, ConfigLine *begin, ConfigLine *end, sstr_t line); |
|
126 int parse_ace(ACLFile *f, sstr_t line); |
|
127 |
|
128 #ifdef __cplusplus |
|
129 } |
|
130 #endif |
|
131 |
|
132 #endif /* _CONFIG_ACL_H */ |
|
133 |