Sun, 23 Nov 2025 13:45:55 +0100
add apply_location_config SAF
| 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 | #include <stdio.h> | |
| 30 | #include <stdlib.h> | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
31 | #include <unistd.h> |
| 51 | 32 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
33 | #include "../util/util.h" |
| 51 | 34 | #include "../util/pool.h" |
| 141 | 35 | #include "../util/pblock.h" |
| 51 | 36 | #include "../safs/auth.h" |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
37 | #include "log.h" |
| 51 | 38 | #include "acl.h" |
| 39 | ||
| 141 | 40 | #define AUTH_TYPE_BASIC "basic" |
| 41 | ||
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
42 | int acllist_createhandle(Session *sn, Request *rq) { |
| 51 | 43 | ACLListHandle *handle = pool_malloc(sn->pool, sizeof(ACLListHandle)); |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
44 | if(!handle) { |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
45 | return 1; |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
46 | } |
| 51 | 47 | handle->defaultauthdb = NULL; |
| 48 | handle->listhead = NULL; | |
| 49 | handle->listtail = NULL; | |
| 50 | rq->acllist = handle; | |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
51 | return 0; |
| 51 | 52 | } |
| 53 | ||
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
54 | /* |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
55 | * append or prepend an ACL |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
56 | */ |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
57 | int acllist_add(Session *sn, Request *rq, ACLList *acl, int append) { |
| 51 | 58 | if(!rq->acllist) { |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
59 | if(acllist_createhandle(sn, rq)) { |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
60 | return 1; |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
61 | } |
| 51 | 62 | } |
| 63 | ACLListHandle *list = rq->acllist; | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
64 | |
| 51 | 65 | if(!list->defaultauthdb && acl->authdb) { |
| 66 | list->defaultauthdb = acl->authdb; | |
| 67 | } | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
68 | |
| 51 | 69 | ACLListElm *elm = pool_malloc(sn->pool, sizeof(ACLListElm)); |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
70 | if(!elm) { |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
71 | return 1; |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
72 | } |
| 51 | 73 | elm->acl = acl; |
| 74 | elm->next = NULL; | |
| 75 | if(list->listhead == NULL) { | |
| 76 | list->listhead = elm; | |
| 77 | list->listtail = elm; | |
| 78 | } else { | |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
79 | if(append) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
80 | list->listtail->next = elm; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
81 | list->listtail = elm; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
82 | } else { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
83 | elm->next = list->listhead; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
84 | list->listhead = elm; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
85 | } |
| 51 | 86 | } |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
87 | return 0; |
| 51 | 88 | } |
| 89 | ||
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
90 | int acllist_append(Session *sn, Request *rq, ACLList *acl) { |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
91 | return acllist_add(sn, rq, acl, 1); |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
92 | } |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
93 | |
|
638
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
94 | int acllist_prepend(Session *sn, Request *rq, ACLList *acl) { |
|
14ae3d8c01ae
add apply_location_config SAF
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
470
diff
changeset
|
95 | return acllist_add(sn, rq, acl, 0); |
| 51 | 96 | } |
| 97 | ||
| 54 | 98 | uint32_t acl_oflag2mask(int oflags) { |
| 99 | /* TODO: | |
| 100 | * maybe there is a plattform where O_RDWR is not O_RDONLY | O_WRONLY | |
| 101 | */ | |
| 102 | uint32_t access_mask = 0; | |
| 103 | if((oflags & O_RDONLY) == O_RDONLY) { | |
| 104 | access_mask |= ACL_READ_DATA; | |
| 105 | } | |
| 106 | if((oflags & O_WRONLY) == O_WRONLY) { | |
| 107 | access_mask |= ACL_WRITE_DATA; | |
| 108 | } | |
| 109 | return access_mask; | |
| 110 | } | |
| 51 | 111 | |
| 54 | 112 | User* acllist_getuser(Session *sn, Request *rq, ACLListHandle *list) { |
|
261
f2c772336ecd
add some references to issues
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
260
diff
changeset
|
113 | // TODO: cache result #50 |
| 54 | 114 | if(!sn || !rq || !list) { |
| 115 | return NULL; | |
| 51 | 116 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
117 | |
| 51 | 118 | // get user |
| 119 | User *user = NULL; | |
| 120 | if(list->defaultauthdb) { | |
| 121 | char *usr; | |
| 122 | char *pw; | |
| 123 | if(!basicauth_getuser(sn, rq, &usr, &pw)) { | |
|
66
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
124 | int pwok; |
|
467
4d038bc6f86e
refactore ldap_auth to use resource pools
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
453
diff
changeset
|
125 | user = authdb_get_and_verify(list->defaultauthdb, sn, rq, usr, pw, &pwok); |
| 51 | 126 | if(!user) { |
|
66
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
127 | // wrong user or wrong password |
| 54 | 128 | return NULL; |
| 51 | 129 | } |
| 130 | // ok - user is authenticated | |
| 141 | 131 | pblock_kvinsert( |
| 132 | pb_key_auth_user, | |
| 133 | user->name, | |
| 134 | strlen(user->name), | |
| 135 | rq->vars); | |
| 136 | pblock_kvinsert( | |
| 137 | pb_key_auth_type, | |
| 138 | AUTH_TYPE_BASIC, | |
| 139 | sizeof(AUTH_TYPE_BASIC)-1, | |
| 140 | rq->vars); | |
| 51 | 141 | } |
| 54 | 142 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
143 | |
| 54 | 144 | return user; |
| 145 | } | |
| 146 | ||
| 147 | void acl_set_error_status(Session *sn, Request *rq, ACLList *acl, User *user) { | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
148 | if(sn == NULL || rq == NULL) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
149 | return; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
150 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
151 | |
| 54 | 152 | if(!user) { |
| 153 | char *value = NULL; | |
| 154 | if(acl->authprompt) { | |
| 155 | size_t realmlen = strlen(acl->authprompt); | |
| 156 | size_t len = realmlen + 16; | |
| 157 | value = pool_malloc(sn->pool, len); | |
| 158 | if(value) { | |
| 159 | snprintf( | |
| 160 | value, | |
| 161 | len, | |
| 162 | "Basic realm=\"%s\"", | |
| 163 | acl->authprompt); | |
| 164 | } | |
| 165 | } | |
| 166 | if(!value) { | |
| 167 | value = "Basic realm=\"login\""; | |
| 168 | } | |
| 169 | pblock_nvinsert("www-authenticate", value, rq->srvhdrs); | |
| 170 | protocol_status(sn, rq, PROTOCOL_UNAUTHORIZED, NULL); | |
| 51 | 171 | } else { |
| 54 | 172 | protocol_status(sn, rq, PROTOCOL_FORBIDDEN, NULL); |
| 173 | } | |
| 174 | } | |
| 175 | ||
| 176 | int acl_evaluate(Session *sn, Request *rq, int access_mask) { | |
| 177 | ACLListHandle *list = rq->acllist; | |
| 178 | if(!list) { | |
| 179 | return REQ_PROCEED; | |
| 180 | } | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
181 | |
| 54 | 182 | // we combine access_mask with the required access rights |
| 183 | access_mask |= rq->aclreqaccess; | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
184 | |
| 54 | 185 | // get user |
| 186 | User *user = acllist_getuser(sn, rq, list); | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
187 | |
| 54 | 188 | // evalutate all ACLs |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
189 | ACLList *acl = acl_evallist(list, user, access_mask, NULL); |
| 54 | 190 | if(acl) { |
| 191 | acl_set_error_status(sn, rq, acl, user); | |
| 51 | 192 | return REQ_ABORTED; |
| 193 | } | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
194 | |
| 54 | 195 | return REQ_PROCEED; |
| 196 | } | |
| 197 | ||
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
198 | ACLList* acl_evallist( |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
199 | ACLListHandle *list, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
200 | User *user, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
201 | int access_mask, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
202 | ACLList **externacl) |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
203 | { |
| 54 | 204 | if(!list) { |
| 205 | return NULL; | |
| 206 | } | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
207 | if(externacl) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
208 | *externacl = NULL; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
209 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
210 | |
| 51 | 211 | // evaluate each acl until one denies access |
| 212 | ACLListElm *elm = list->listhead; | |
| 213 | while(elm) { | |
| 214 | ACLList *acl = elm->acl; | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
215 | if(acl->isextern) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
216 | // set externacl to the first external acl |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
217 | if(externacl && *externacl == NULL) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
218 | *externacl = acl; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
219 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
220 | } else if(!acl->check(acl, user, access_mask)) { |
| 51 | 221 | // the acl denies access |
| 54 | 222 | return acl; |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
223 | } |
| 51 | 224 | elm = elm->next; |
| 225 | } | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
226 | |
| 51 | 227 | // ok - all acls allowed access |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
228 | |
| 54 | 229 | return NULL; |
| 51 | 230 | } |
| 231 | ||
| 54 | 232 | int wsacl_affects_user(WSAce *ace, User *user) { |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
233 | int check_access = 0; |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
234 | |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
235 | /* |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
236 | * an ace can affect |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
237 | * a named user or group (ace->who is set) |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
238 | * the owner of the resource (ACL_OWNER is set) |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
239 | * the owning group of the resource (ACL_GROUP is set) |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
240 | * everyone (ACL_EVERYONE is set) |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
241 | * |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
242 | * Only one of this conditions should be true. The behavior on |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
243 | * illegal flag combination is undefined. We assume that the acls |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
244 | * are created correctly by the configuration loader. |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
245 | */ |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
246 | |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
247 | if(ace->who && user) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
248 | // this ace is defined for a named user or group |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
249 | if((ace->flags & ACL_IDENTIFIER_GROUP) == ACL_IDENTIFIER_GROUP) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
250 | if(user->check_group(user, ace->who)) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
251 | // the user is in the group |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
252 | check_access = 1; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
253 | } |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
254 | } else { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
255 | if(!strcmp(user->name, ace->who)) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
256 | check_access = 1; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
257 | } |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
258 | } |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
259 | } else if((ace->flags & ACL_OWNER) == ACL_OWNER) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
260 | // TODO |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
261 | } else if((ace->flags & ACL_GROUP) == ACL_GROUP) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
262 | // TODO |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
263 | } else if((ace->flags & ACL_EVERYONE) == ACL_EVERYONE) { |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
264 | check_access = 1; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
265 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
266 | |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
267 | return check_access; |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
268 | } |
|
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
269 | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
270 | int wsacl_check(WSAcl *acl, User *user, int access_mask) { |
| 51 | 271 | int allow = 0; |
| 272 | uint32_t allowed_access = 0; | |
| 273 | // check each access control entry | |
| 274 | for(int i=0;i<acl->acenum;i++) { | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
275 | WSAce *ace = acl->ace[i]; |
|
52
aced2245fb1c
new pathcheck saf and code cleanup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
276 | if(wsacl_affects_user(ace, user)) { |
| 51 | 277 | if(ace->type == ACL_TYPE_ALLOWED) { |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
278 | // add all new access rights |
| 54 | 279 | allowed_access |= (access_mask & ace->access_mask); |
| 51 | 280 | // check if we have all requested rights |
| 281 | if((allowed_access & access_mask) == access_mask) { | |
| 282 | allow = 1; | |
| 283 | break; | |
| 284 | } | |
| 285 | } else { | |
| 286 | // ACL_TYPE_DENIED | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
287 | |
| 51 | 288 | if((ace->access_mask & access_mask) != 0) { |
| 289 | // access denied | |
| 290 | break; | |
| 291 | } | |
| 292 | } | |
| 293 | } | |
| 294 | } | |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
295 | |
| 51 | 296 | // TODO: events |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
297 | |
| 54 | 298 | return allow; // allow is 0, if no ace set it to 1 |
| 51 | 299 | } |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
300 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
301 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
302 | /* filesystem acl functions */ |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
303 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
304 | #if defined (__SVR4) && defined (__sun) |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
305 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
306 | #include <sys/acl.h> |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
307 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
308 | int solaris_acl_check( |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
309 | char *path, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
310 | struct stat *s, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
311 | uint32_t mask, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
312 | uid_t uid, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
313 | gid_t gid); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
314 | int solaris_acl_affects_user( |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
315 | ace_t *ace, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
316 | uid_t uid, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
317 | gid_t gid, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
318 | uid_t owner, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
319 | gid_t owninggroup); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
320 | |
|
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
321 | int fs_acl_check(SysACL *acl, User *user, const char *path, uint32_t access_mask) { |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
322 | cxmutstr p; |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
323 | if(path[0] != '/') { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
324 | size_t n = 128; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
325 | char *cwd = malloc(n); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
326 | while(!getcwd(cwd, n)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
327 | if(errno == ERANGE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
328 | n *= 2; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
329 | cwd = realloc(cwd, n); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
330 | } else { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
331 | free(cwd); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
332 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
333 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
334 | } |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
335 | cxmutstr wd = cx_str(cwd); |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
336 | cxmutstr pp = cx_str((char*)path); |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
337 | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
338 | p = cx_strcat(3, wd, cx_strn("/", 1), pp); |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
339 | } else { |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
340 | p = cx_strdup(cx_str((char*)path)); |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
341 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
342 | if(p.ptr[p.length-1] == '/') { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
343 | p.ptr[p.length-1] = 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
344 | p.length--; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
345 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
346 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
347 | // get uid/gid |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
348 | struct passwd pw; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
349 | if(user) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
350 | char *pwbuf = malloc(DEF_PWBUF); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
351 | if(pwbuf == NULL) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
352 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
353 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
354 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
355 | if(!util_getpwnam(user->name, &pw, pwbuf, DEF_PWBUF)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
356 | free(pwbuf); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
357 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
358 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
359 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
360 | free(pwbuf); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
361 | acl->user_uid = pw.pw_uid; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
362 | acl->user_gid = pw.pw_gid; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
363 | } else { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
364 | acl->user_uid = -1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
365 | acl->user_gid = -1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
366 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
367 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
368 | // translate access_mask |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
369 | uint32_t mask = 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
370 | if((access_mask & ACL_READ_DATA) == ACL_READ_DATA) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
371 | mask |= ACE_READ_DATA; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
372 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
373 | if((access_mask & ACL_WRITE_DATA) == ACL_WRITE_DATA) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
374 | mask |= ACE_WRITE_DATA; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
375 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
376 | if((access_mask & ACL_ADD_FILE) == ACL_ADD_FILE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
377 | mask |= ACE_ADD_FILE; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
378 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
379 | if((access_mask & ACL_READ_XATTR) == ACL_READ_XATTR) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
380 | mask |= ACE_READ_NAMED_ATTRS; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
381 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
382 | if((access_mask & ACL_WRITE_XATTR) == ACL_WRITE_XATTR) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
383 | mask |= ACE_WRITE_NAMED_ATTRS; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
384 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
385 | if((access_mask & ACL_EXECUTE) == ACL_EXECUTE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
386 | mask |= ACE_EXECUTE; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
387 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
388 | if((access_mask & ACL_DELETE) == ACL_DELETE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
389 | mask |= ACE_DELETE_CHILD; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
390 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
391 | if((access_mask & ACL_READ_ATTRIBUTES) == ACL_READ_ATTRIBUTES) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
392 | mask |= ACE_READ_ATTRIBUTES; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
393 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
394 | if((access_mask & ACL_WRITE_ATTRIBUTES) == ACL_WRITE_ATTRIBUTES) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
395 | mask |= ACE_WRITE_ATTRIBUTES; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
396 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
397 | if((access_mask & ACL_LIST) == ACL_LIST) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
398 | mask |= ACE_LIST_DIRECTORY; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
399 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
400 | if((access_mask & ACL_READ_ACL) == ACL_READ_ACL) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
401 | mask |= ACE_READ_ACL; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
402 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
403 | if((access_mask & ACL_WRITE_ACL) == ACL_WRITE_ACL) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
404 | mask |= ACE_WRITE_ACL; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
405 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
406 | if((access_mask & ACL_WRITE_OWNER) == ACL_WRITE_OWNER) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
407 | mask |= ACE_WRITE_OWNER; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
408 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
409 | if((access_mask & ACL_SYNCHRONIZE) == ACL_SYNCHRONIZE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
410 | mask |= ACE_SYNCHRONIZE; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
411 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
412 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
413 | /* |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
414 | * If the vfs wants to create new files, path does not name an existing |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
415 | * file. In this case, we check if the user has the ACE_ADD_FILE |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
416 | * permission for the parent directory |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
417 | */ |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
418 | struct stat s; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
419 | if(stat(p.ptr, &s)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
420 | if(errno != ENOENT) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
421 | perror("fs_acl_check: stat"); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
422 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
423 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
424 | } else { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
425 | mask = ACE_ADD_FILE; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
426 | p = util_path_remove_last(p); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
427 | if(stat(p.ptr, &s)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
428 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
429 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
430 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
431 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
432 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
433 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
434 | /* |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
435 | * perform a acl check for the path and each parent directory |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
436 | * we don't check the file system root |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
437 | * |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
438 | * after the first check, we check only search permission for the |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
439 | * directories |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
440 | */ |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
441 | if(!solaris_acl_check(p.ptr, &s, mask, pw.pw_uid, pw.pw_gid)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
442 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
443 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
444 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
445 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
446 | p = util_path_remove_last(p); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
447 | mask = ACE_LIST_DIRECTORY; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
448 | while(p.length > 1) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
449 | if(stat(p.ptr, &s)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
450 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
451 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
452 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
453 | if(!solaris_acl_check(p.ptr, &s, mask, pw.pw_uid, pw.pw_gid)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
454 | free(p.ptr); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
455 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
456 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
457 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
458 | // cut the last file name from the path |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
459 | p = util_path_remove_last(p); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
460 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
461 | |
|
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
462 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
463 | return 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
464 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
465 | |
|
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
466 | int fs_acl_check_fd(SysACL *acl, User *user, int fd, uint32_t access_mask) { |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
467 | // TODO: |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
468 | return 1; |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
469 | } |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
470 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
471 | int solaris_acl_check( |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
472 | char *path, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
473 | struct stat *s, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
474 | uint32_t mask, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
475 | uid_t uid, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
476 | gid_t gid) |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
477 | { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
478 | //printf("solaris_acl_check %s\n", path); |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
479 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
480 | int nace = acl(path, ACE_GETACLCNT, 0, NULL); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
481 | if(nace == -1) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
482 | perror("acl: ACE_GETACLCNT"); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
483 | // TODO: log error |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
484 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
485 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
486 | ace_t *aces = calloc(nace, sizeof(ace_t)); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
487 | if(acl(path, ACE_GETACL, nace, aces) == 1) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
488 | perror("acl: ACE_GETACL"); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
489 | // TODO: log error |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
490 | free(aces); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
491 | return 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
492 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
493 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
494 | int allow = 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
495 | uint32_t allowed_access = 0; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
496 | for(int i=0;i<nace;i++) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
497 | ace_t ace = aces[i]; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
498 | if(solaris_acl_affects_user(&ace, uid, gid, s->st_uid, s->st_gid)) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
499 | if(ace.a_type == ACE_ACCESS_ALLOWED_ACE_TYPE) { |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
500 | // add all new access rights |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
501 | allowed_access |= (mask & ace.a_access_mask); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
502 | // check if we have all requested rights |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
503 | if((allowed_access & mask) == mask) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
504 | allow = 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
505 | break; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
506 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
507 | } else if(ace.a_type == ACE_ACCESS_DENIED_ACE_TYPE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
508 | // ACL_TYPE_DENIED |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
509 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
510 | if((ace.a_access_mask & mask) != 0) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
511 | // access denied |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
512 | break; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
513 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
514 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
515 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
516 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
517 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
518 | free(aces); |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
519 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
520 | //printf("return %d\n", allow); |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
521 | return allow; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
522 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
523 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
524 | int solaris_acl_affects_user( |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
525 | ace_t *ace, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
526 | uid_t uid, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
527 | gid_t gid, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
528 | uid_t owner, |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
529 | gid_t owninggroup) |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
530 | { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
531 | /* |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
532 | * mostly the same as wsacl_affects_user |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
533 | */ |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
534 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
535 | int check_access = 0; |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
536 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
537 | if((ace->a_flags & ACE_OWNER) == ACE_OWNER) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
538 | if(uid == owner) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
539 | check_access = 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
540 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
541 | } else if((ace->a_flags & ACE_GROUP) == ACE_GROUP) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
542 | if(gid == owninggroup) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
543 | check_access = 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
544 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
545 | } else if((ace->a_flags & ACE_EVERYONE) == ACE_EVERYONE) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
546 | check_access = 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
547 | } else if(ace->a_who != -1 && uid != 0) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
548 | // this ace is defined for a named user or group |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
549 | if((ace->a_flags & ACE_IDENTIFIER_GROUP) == ACE_IDENTIFIER_GROUP) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
550 | // TODO: check all groups |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
551 | if(ace->a_who == gid) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
552 | // the user is in the group |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
553 | check_access = 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
554 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
555 | } else { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
556 | if(ace->a_who == uid) { |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
557 | check_access = 1; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
558 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
559 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
560 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
561 | |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
562 | return check_access; |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
563 | } |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
564 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
565 | void fs_acl_finish() { |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
566 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
567 | } |
|
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
568 | |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
569 | #endif |
|
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
570 | |
|
69
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
571 | /* |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
572 | * generic code for all non acl unices |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
573 | * TODO: don't use OSX in the preprocessor directive |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
574 | */ |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
575 | #ifdef OSX |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
576 | |
|
453
4586d534f9b5
fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
577 | int fs_acl_check(SysACL *acl, User *user, const char *path, uint32_t access_mask) { |
|
69
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
578 | return 1; |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
579 | } |
|
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
580 | |
|
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
581 | int fs_acl_check_fd(SysACL *acl, User *user, int fd, uint32_t access_mask) { |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
582 | return 1; |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
583 | } |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
584 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
585 | void fs_acl_finish() { |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
586 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
587 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
588 | |
|
69
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
589 | #endif |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
590 | |
|
453
4586d534f9b5
fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
591 | #if defined(BSD) && !defined(OSX) |
|
109
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
592 | |
|
260
4779a6fb4fbe
fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
593 | int fs_acl_check(SysACL *acl, User *user, const char *path, uint32_t access_mask) { |
|
109
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
594 | return 1; |
|
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
595 | } |
|
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
596 | |
|
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
597 | int fs_acl_check_fd(SysACL *acl, User *user, int fd, uint32_t access_mask) { |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
598 | return 1; |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
599 | } |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
600 | |
|
109
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
601 | void fs_acl_finish() { |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
602 | |
|
109
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
603 | } |
|
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
604 | |
|
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
605 | #endif |
|
8a0a7754f123
experimental BSD support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
100
diff
changeset
|
606 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
607 | |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
608 | #ifdef LINUX |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
609 | |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
610 | #include <sys/fsuid.h> |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
611 | |
|
260
4779a6fb4fbe
fix freebsd build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
612 | int fs_acl_check(SysACL *acl, User *user, const char *path, uint32_t access_mask) { |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
613 | struct passwd *ws_pw = conf_getglobals()->Vuserpw; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
614 | if(!ws_pw) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
615 | log_ereport(LOG_FAILURE, "fs_acl_check: unknown webserver uid/gid"); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
616 | return 1; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
617 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
618 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
619 | // get uid/gid |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
620 | struct passwd pw; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
621 | if(user) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
622 | char *pwbuf = malloc(DEF_PWBUF); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
623 | if(pwbuf == NULL) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
624 | return 0; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
625 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
626 | if(!util_getpwnam(user->name, &pw, pwbuf, DEF_PWBUF)) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
627 | free(pwbuf); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
628 | return 0; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
629 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
630 | free(pwbuf); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
631 | acl->user_uid = pw.pw_uid; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
632 | acl->user_gid = pw.pw_gid; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
633 | } else { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
634 | acl->user_uid = 0; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
635 | acl->user_gid = 0; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
636 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
637 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
638 | // set fs uid/gid |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
639 | if(acl->user_uid != 0) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
640 | if(setfsuid(pw.pw_uid)) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
641 | log_ereport( |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
642 | LOG_FAILURE, |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
643 | "Cannot set fsuid to uid: %u", pw.pw_uid); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
644 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
645 | if(setfsgid(pw.pw_gid)) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
646 | log_ereport( |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
647 | LOG_FAILURE, |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
648 | "Cannot set fsgid to gid: %u", pw.pw_gid); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
649 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
650 | } |
|
202
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
651 | |
|
c374d11d6720
remove libnsl from linux makefile
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
652 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
653 | return 1; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
654 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
655 | |
|
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
656 | int fs_acl_check_fd(SysACL *acl, User *user, int fd, uint32_t access_mask) { |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
657 | // TODO |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
658 | return 1; |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
659 | } |
|
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
202
diff
changeset
|
660 | |
|
73
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
661 | void fs_acl_finish() { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
662 | struct passwd *pw = conf_getglobals()->Vuserpw; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
663 | if(!pw) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
664 | log_ereport( |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
665 | LOG_FAILURE, |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
666 | "global configuration broken (Vuserpw is null)"); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
667 | return; |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
668 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
669 | if(setfsuid(pw->pw_uid)) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
670 | log_ereport( |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
671 | LOG_FAILURE, |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
672 | "Cannot set fsuid back to server uid: %u", pw->pw_uid); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
673 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
674 | if(setfsgid(pw->pw_gid)) { |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
675 | log_ereport( |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
676 | LOG_FAILURE, |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
677 | "Cannot set fsgid back to server gid: %u", pw->pw_gid); |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
678 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
679 | } |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
680 | |
|
79fa26ecd135
added file system ACLs for linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
69
diff
changeset
|
681 | #endif |