Sun, 27 Nov 2022 10:07:37 +0100
fix listener ssl initialization
51 | 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 | ||
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
39 | #define CFG_ACE_ADD(list_begin, elm) \ |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
40 | cx_linked_list_add((void**)list_begin, NULL, -1, offsetof(ACEConfig, next), elm) |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
41 | |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
42 | #define CFG_ACE_LIST_SIZE(list) \ |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
43 | cx_linked_list_size(list, offsetof(ACEConfig, next)) |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
44 | |
51 | 45 | typedef struct _acl_conf ACLConfig; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
46 | typedef struct _ace_conf ACEConfig; |
51 | 47 | |
48 | typedef struct _acl_file { | |
49 | ConfigParser parser; | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
50 | CxList *namedACLs; // ACLConfig list |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
51 | CxList *uriACLs; // ACLConfig list |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
52 | CxList *pathACLs; // ACLConfig list |
51 | 53 | // temp data |
54 | ACLConfig *cur; | |
55 | } ACLFile; | |
56 | ||
57 | struct _acl_conf { | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
58 | cxmutstr id; // name, uri or path |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
59 | cxmutstr type; // webserver ACL or file system ACL |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
60 | ConfigParam *authparam; // authentication parameters |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
61 | ACEConfig *entries; // ACEConfig list |
51 | 62 | }; |
63 | ||
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
64 | struct _ace_conf { |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
65 | cxmutstr who; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
66 | uint32_t access_mask; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
67 | uint16_t flags; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
68 | uint16_t type; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
69 | ACEConfig *next; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
70 | }; |
51 | 71 | |
72 | ||
73 | /* | |
74 | * the flags are a duplicate of the webserver's acl flags | |
75 | */ | |
76 | ||
77 | /* | |
78 | * access permissions | |
79 | */ | |
80 | #define ACLCFG_READ_DATA 0x0001 | |
81 | #define ACLCFG_WRITE_DATA 0x0002 | |
82 | #define ACLCFG_APPEND 0x0002 | |
83 | #define ACLCFG_ADD_FILE 0x0004 | |
84 | #define ACLCFG_ADD_SUBDIRECTORY 0x0004 | |
85 | #define ACLCFG_READ_XATTR 0x0008 | |
86 | #define ACLCFG_WRITE_XATTR 0x0010 | |
87 | #define ACLCFG_EXECUTE 0x0020 | |
88 | #define ACLCFG_DELETE_CHILD 0x0040 | |
89 | #define ACLCFG_DELETE 0x0040 | |
90 | #define ACLCFG_READ_ATTRIBUTES 0x0080 | |
91 | #define ACLCFG_WRITE_ATTRIBUTES 0x0100 | |
92 | #define ACLCFG_LIST 0x0200 | |
93 | #define ACLCFG_READ_ACL 0x0400 | |
94 | #define ACLCFG_WRITE_ACL 0x0800 | |
95 | #define ACLCFG_WRITE_OWNER 0x1000 | |
96 | #define ACLCFG_SYNCHRONIZE 0x2000 | |
97 | ||
98 | #define ACLCFG_READ \ | |
99 | (ACLCFG_READ_DATA|ACLCFG_READ_XATTR|ACLCFG_READ_ATTRIBUTES) | |
100 | #define ACLCFG_WRITE \ | |
394
4d2a1df73e18
"write" permission includes "add_file" now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
101 | (ACLCFG_WRITE_DATA|ACLCFG_ADD_FILE|ACLCFG_WRITE_XATTR|ACLCFG_WRITE_ATTRIBUTES) |
51 | 102 | |
103 | /* | |
104 | * ace flags | |
105 | */ | |
106 | #define ACLCFG_FILE_INHERIT 0x0001 | |
107 | #define ACLCFG_DIR_INHERIT 0x0002 | |
108 | #define ACLCFG_NO_PROPAGATE 0x0004 | |
109 | #define ACLCFG_INHERIT_ONLY 0x0008 | |
110 | #define ACLCFG_SUCCESSFUL_ACCESS_FLAG 0x0010 | |
111 | #define ACLCFG_FAILED_ACCESS_ACE_FLAG 0x0020 | |
112 | #define ACLCFG_IDENTIFIER_GROUP 0x0040 | |
113 | #define ACLCFG_OWNER 0x1000 | |
114 | #define ACLCFG_GROUP 0x2000 | |
115 | #define ACLCFG_EVERYONE 0x4000 | |
116 | ||
117 | /* | |
118 | * ace type | |
119 | */ | |
120 | #define ACLCFG_TYPE_ALLOWED 0x01 | |
121 | #define ACLCFG_TYPE_DENIED 0x02 | |
122 | #define ACLCFG_TYPE_AUDIT 0x03 | |
123 | #define ACLCFG_TYPE_ALARM 0x04 | |
124 | ||
125 | ||
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
126 | ACLFile* load_acl_file(const char *file); |
51 | 127 | |
128 | void free_acl_file(ACLFile *aclfile); | |
129 | ||
130 | ||
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
131 | int acl_parse(void *p, ConfigLine *begin, ConfigLine *end, cxmutstr line); |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
132 | int parse_ace(ACLFile *f, cxmutstr line); |
51 | 133 | |
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
134 | /* |
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
135 | * converts a access right string to an integer value |
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
136 | */ |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
394
diff
changeset
|
137 | uint32_t accstr2int(cxstring access); |
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
138 | |
51 | 139 | #ifdef __cplusplus |
140 | } | |
141 | #endif | |
142 | ||
143 | #endif /* _CONFIG_ACL_H */ | |
144 |