Debian Codegraph @

include/public/nsacl/acldef.h

raw
1 /** BEGIN COPYRIGHT BLOCK
2 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3 * Copyright (C) 2005 Red Hat, Inc.
4 * All rights reserved.
5 *
6 * License: GPL (version 3 or any later version).
7 * See LICENSE for details.
8 * END COPYRIGHT BLOCK **/
9
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14 #ifndef PUBLIC_NSACL_ACLDEF_H
15 #define PUBLIC_NSACL_ACLDEF_H
16
17 /*
18 * File: acldef.h
19 *
20 * Description:
21 *
22 * This file contains constant and type definitions for the ACL API.
23 */
24
25 #ifndef PUBLIC_NSACL_NSERRDEF_H
26 #include "nserrdef.h"
27 #endif /* !PUBLIC_NSACL_NSERRDEF_H */
28
29 #ifndef PUBLIC_NSACL_PLISTDEF_H
30 #include "plistdef.h"
31 #endif /* !PUBLIC_NSACL_PLISTDEF_H */
32
33 NSPR_BEGIN_EXTERN_C
34
35 /*
36 * Type: ACLCachable_t
37 *
38 * Description:
39 *
40 * This type is used to specify whether and how long something
41 * may be safely cached. A value of zero (ACL_NOT_CACHABLE)
42 * indicates that the item is not cachable. Any other value is
43 * a time, in seconds since 00:00:00 UTC, January 1, 1970, after
44 * which the cached information should be discarded.
45 */
46
47 typedef unsigned long ACLCachable_t;
48
49 #define ACL_NOT_CACHABLE 0
50 #define ACL_INDEF_CACHABLE ((unsigned long)(-1))
51
52 /*
53 * Type: ACLListHandle_t
54 *
55 * Description:
56 *
57 * This type represents a list of ACLs in their in-memory form.
58 */
59
60 typedef struct ACLListHandle ACLListHandle_t;
61
62 /* The object has been checked for ACLs and has none attached */
63 #define ACL_LIST_NO_ACLS ((ACLListHandle_t *)-1)
64
65 /*
66 * Type: ACLHandle_t
67 *
68 * Description:
69 *
70 * This type represents the in-memory form of an ACL.
71 */
72
73 typedef struct ACLHandle ACLHandle_t;
74
75 /*
76 * Type: ACLListEnum_t
77 *
78 * Description:
79 *
80 * This type contains the state of an ACL list enumeration.
81 */
82
83 typedef void *ACLListEnum_t;
84
85 /*
86 * Type: ACLExprHandle_t
87 *
88 * Description:
89 *
90 * This type represents a single ACL entry, e.g. allow, deny, etc.
91 */
92
93 typedef struct ACLExprHandle ACLExprHandle_t;
94
95 /*
96 * Type: ACLEvalHandle_t
97 *
98 * Description:
99 *
100 * This type represents an ACL evaluation context, which includes
101 * an ACL list and property lists for the subject and resource.
102 */
103
104 typedef struct ACLEvalHandle ACLEvalHandle_t;
105
106 /*
107 * Type: PFlags_t
108 *
109 * Description:
110 *
111 * This type represents a set of processing flags for an ACL entry.
112 */
113 typedef int PFlags_t;
114
115 #define ACL_PFLAG_ABSOLUTE 0x1
116 #define ACL_PFLAG_TERMINAL 0x2
117 #define ACL_PFLAG_CONTENT 0x4
118
119 #define IS_ABSOLUTE(x) ((x)&ACL_PFLAG_ABSOLUTE)
120 #define IS_STATIC(x) ((x)&ACL_PFLAG_STATIC)
121 #define IS_CONTENT(x) ((x)&ACL_PFLAG_CONTENT)
122
123 /*
124 * Type: CmpOp_t
125 *
126 * Description:
127 *
128 * This type represents a comparison operator in an ACL attribute
129 * expression.
130 */
131 typedef enum {
132 CMP_OP_EQ,
133 CMP_OP_NE,
134 CMP_OP_GT,
135 CMP_OP_LT,
136 CMP_OP_GE,
137 CMP_OP_LE
138 } CmpOp_t;
139
140 /*
141 * Type: ACLExprType_t
142 *
143 * Description:
144 *
145 * This type represents the type of an ACL entry.
146 */
147 typedef enum {
148 ACL_EXPR_TYPE_ALLOW,
149 ACL_EXPR_TYPE_DENY,
150 ACL_EXPR_TYPE_AUTH,
151 ACL_EXPR_TYPE_RESPONSE
152 } ACLExprType_t;
153
154 /*
155 * Type: ACLEvalRes_t
156 *
157 * Description:
158 *
159 * This type represents the result of ACL evaluation.
160 */
161 typedef enum {
162 ACL_RES_ALLOW,
163 ACL_RES_DENY,
164 ACL_RES_FAIL,
165 ACL_RES_INVALID,
166 ACL_RES_NONE
167 } ACLEvalRes_t;
168
169 /*
170 * Type: ACLMethod_t
171 *
172 * Description:
173 *
174 * This type represents a reference to an authentication method.
175 */
176 typedef void *ACLMethod_t;
177
178 #define ACL_METHOD_ANY ((ACLMethod_t)-1)
179 #define ACL_METHOD_INVALID ((ACLMethod_t)-2)
180
181 /*
182 * Type: ACLDbType_t
183 *
184 * Description:
185 *
186 * This type represents a reference to a type of authentication
187 * database.
188 */
189 typedef void *ACLDbType_t;
190
191 #define ACL_DBTYPE_ANY ((ACLDbType_t)-1)
192 #define ACL_DBTYPE_INVALID ((ACLDbType_t)-2)
193
194 /*
195 * Type: ACLAttrGetterFn_t
196 *
197 * Description:
198 *
199 * This type describes a kind of callback function that obtains
200 * a value for an ACL attribute and enters the attribute and value
201 * into the subject property list.
202 */
203 typedef int (*ACLAttrGetterFn_t)(NSErr_t *errp, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth, void *arg);
204
205 typedef struct ACLAttrGetter ACLAttrGetter_t;
206 typedef void *ACLAttrGetterList_t;
207
208 /*
209 * Type: AclModuleInitFunc
210 *
211 * Description:
212 *
213 * This type describes a kind of callback function that is
214 * specified to ACL_ModuleRegister() and called from there.
215 * The function should return 0 on success and non-zero on
216 * failure.
217 */
218 typedef int (*AclModuleInitFunc)(NSErr_t *errp);
219
220 /*
221 * Type: DbParseFn_t
222 *
223 * Description:
224 *
225 * This type describes a kind of callback function that parses
226 * a reference to an authentication database of a particular
227 * database type. It is called when ACL_DatabaseRegister() is
228 * called for a database which is that database type.
229 * The function should return 0 on success and non-zero on
230 * failure.
231 */
232 typedef int (*DbParseFn_t)(NSErr_t *errp, ACLDbType_t dbtype, const char *name, const char *url, PList_t plist, void **db);
233
234 /*
235 * Type: AclCacheFlushFunc_t
236 *
237 * Description:
238 *
239 * This type describes a kind of callback function that is called
240 * when ACL_CacheFlush() is called.
241 */
242 typedef int (*AclCacheFlushFunc_t)(void);
243
244 /*
245 * Type: LASEvalFunc_t
246 *
247 * Description:
248 *
249 * This type describes a kind of callback function that is called
250 * to evaluate an attribute value expression in an ACL statement.
251 */
252 typedef int (*LASEvalFunc_t)(NSErr_t *errp, char *attr_name, CmpOp_t comparator, char *attr_pattern, ACLCachable_t *cachable, void **cookie, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth);
253
254 /*
255 * Type: LASFlushFunc_t
256 *
257 * Description:
258 *
259 * This type describes a kind of callback function that is called
260 * when a previously cached LAS cookie is being flushed from
261 * the ACL cache.
262 */
263 typedef void (*LASFlushFunc_t)(void **cookie);
264
265 /*
266 * Type: LDAP
267 *
268 * Description:
269 *
270 * This is an opaque type that represents an open LDAP connection.
271 * It is used mostly via the LDAP SDK API.
272 * Include the <ldap.h> file before including this file if you wish to
273 * use the function ACL_LDAPDatabaseHandle.
274 */
275 #ifndef _LDAP_H
276 typedef struct ldap LDAP;
277 #endif /* _LDAP_H */
278
279
280 /* Flags to ACL_ListFind */
281 #define ACL_CASE_INSENSITIVE 0x1
282 #define ACL_CASE_SENSITIVE 0x2
283
284 #define ACL_MAX_TEST_RIGHTS 32
285 #define ACL_MAX_GENERIC 32
286
287 /*
288 * ACLERRFAIL -- Use this as an 'retcode' argument to nserrGenerate.
289 */
290 #define ACLERRFAIL -11
291
292
293 /*
294 * Command values for the "position" argument to ACL_RegisterGetter
295 * Any positive >0 value is the specific position in the list to insert
296 * the new function.
297 */
298 #define ACL_AT_FRONT 0
299 #define ACL_AT_END -1
300 #define ACL_REPLACE_ALL -2
301 #define ACL_REPLACE_MATCHING -3
302
303 #define ACL_ATTR_GROUP "group"
304 #define ACL_ATTR_GROUP_INDEX 1
305 #define ACL_ATTR_RAW_USER_LOGIN "user-login"
306 #define ACL_ATTR_RAW_USER_LOGIN_INDEX 2
307 #define ACL_ATTR_AUTH_USER "auth-user"
308 #define ACL_ATTR_AUTH_USER_INDEX 3
309 #define ACL_ATTR_AUTH_TYPE "auth-type"
310 #define ACL_ATTR_AUTH_TYPE_INDEX 4
311 #define ACL_ATTR_AUTH_DB "auth-db"
312 #define ACL_ATTR_AUTH_DB_INDEX 5
313 #define ACL_ATTR_AUTH_PASSWORD "auth-password"
314 #define ACL_ATTR_AUTH_PASSWORD_INDEX 6
315 #define ACL_ATTR_USER "user"
316 #define ACL_ATTR_USER_INDEX 7
317 #define ACL_ATTR_PASSWORD "pw"
318 #define ACL_ATTR_PASSWORD_INDEX 8
319 #define ACL_ATTR_USERDN "userdn"
320 #define ACL_ATTR_USERDN_INDEX 9
321 #define ACL_ATTR_RAW_USER "raw-user"
322 #define ACL_ATTR_RAW_USER_INDEX 10
323 #define ACL_ATTR_RAW_PASSWORD "raw-pw"
324 #define ACL_ATTR_RAW_PASSWORD_INDEX 11
325 #define ACL_ATTR_USER_ISMEMBER "user-ismember"
326 #define ACL_ATTR_USER_ISMEMBER_INDEX 12
327 #define ACL_ATTR_DATABASE "database"
328 #define ACL_ATTR_DATABASE_INDEX 13
329 #define ACL_ATTR_DBTYPE "dbtype"
330 #define ACL_ATTR_DBTYPE_INDEX 14
331 #define ACL_ATTR_DBNAME "dbname"
332 #define ACL_ATTR_DBNAME_INDEX 15
333 #define ACL_ATTR_DATABASE_URL "url"
334 #define ACL_ATTR_DATABASE_URL_INDEX 16
335 #define ACL_ATTR_METHOD "method"
336 #define ACL_ATTR_METHOD_INDEX 17
337 #define ACL_ATTR_AUTHTYPE "authtype"
338 #define ACL_ATTR_AUTHTYPE_INDEX 18
339 #define ACL_ATTR_AUTHORIZATION "authorization"
340 #define ACL_ATTR_AUTHORIZATION_INDEX 19
341 #define ACL_ATTR_PARSEFN "parsefn"
342 #define ACL_ATTR_PARSEFN_INDEX 20
343 #define ACL_ATTR_ATTRIBUTE "attr"
344 #define ACL_ATTR_ATTRIBUTE_INDEX 21
345 #define ACL_ATTR_GETTERFN "getterfunc"
346 #define ACL_ATTR_GETTERFN_INDEX 22
347 #define ACL_ATTR_IP "ip"
348 #define ACL_ATTR_IP_INDEX 23
349 #define ACL_ATTR_DNS "dns"
350 #define ACL_ATTR_DNS_INDEX 24
351 #define ACL_ATTR_MODULE "module"
352 #define ACL_ATTR_MODULE_INDEX 25
353 #define ACL_ATTR_MODULEFUNC "func"
354 #define ACL_ATTR_MODULEFUNC_INDEX 26
355 #define ACL_ATTR_GROUPS "groups"
356 #define ACL_ATTR_GROUPS_INDEX 27
357 #define ACL_ATTR_IS_VALID_PASSWORD "isvalid-password"
358 #define ACL_ATTR_IS_VALID_PASSWORD_INDEX 28
359 #define ACL_ATTR_CERT2USER "cert2user"
360 #define ACL_ATTR_CERT2USER_INDEX 29
361 #define ACL_ATTR_USER_CERT "cert"
362 #define ACL_ATTR_USER_CERT_INDEX 30
363 #define ACL_ATTR_PROMPT "prompt"
364 #define ACL_ATTR_PROMPT_INDEX 31
365 #define ACL_ATTR_TIME "time"
366 #define ACL_ATTR_TIME_INDEX 32
367 #define ACL_ATTR_USERS_GROUP "users-group"
368 #define ACL_ATTR_USERS_GROUP_INDEX 33
369 #define ACL_ATTR_SESSION "session" /* subject property */
370 #define ACL_ATTR_SESSION_INDEX 34
371 #define ACL_ATTR_REQUEST "request" /* resource property */
372 #define ACL_ATTR_REQUEST_INDEX 35
373 #define ACL_ATTR_ERROR "error"
374 #define ACL_ATTR_ERROR_INDEX 36
375 #define ACL_ATTR_PROGRAMS "programs" /* resource property */
376 #define ACL_ATTR_PROGRAMS_INDEX 37
377 #define ACL_ATTR_ACCEL_AUTH "accel-authorization"
378 #define ACL_ATTR_ACCEL_AUTH_INDEX 38
379 #define ACL_ATTR_WWW_AUTH_PROMPT "www-auth-prompt"
380 #define ACL_ATTR_WWW_AUTH_PROMPT_INDEX 39
381 #define ACL_ATTR_OWNER "owner"
382 #define ACL_ATTR_OWNER_INDEX 40
383 #define ACL_ATTR_IS_OWNER "is-owner"
384 #define ACL_ATTR_IS_OWNER_INDEX 41
385 #define ACL_ATTR_CACHED_USER "cached-user"
386 #define ACL_ATTR_CACHED_USER_INDEX 42
387 #define ACL_ATTR_USER_EXISTS "user-exists"
388 #define ACL_ATTR_USER_EXISTS_INDEX 43
389
390 /* Must be 1 larger than the highest index used */
391 #define ACL_ATTR_INDEX_MAX 44
392
393 #ifdef ALLOCATE_ATTR_TABLE
394 /* Must be in the same order as the index numbers */
395 const char *ACLAttrTable[] = {
396 NULL, /* 0 */
397 /* Don't have one numbered 0 */
398 ACL_ATTR_GROUP, /* 1 */
399 ACL_ATTR_RAW_USER_LOGIN, /* 2 */
400 ACL_ATTR_AUTH_USER, /* 3 */
401 ACL_ATTR_AUTH_TYPE, /* 4 */
402 ACL_ATTR_AUTH_DB, /* 5 */
403 ACL_ATTR_AUTH_PASSWORD, /* 6 */
404 ACL_ATTR_USER, /* 7 */
405 ACL_ATTR_PASSWORD, /* 8 */
406 ACL_ATTR_USERDN, /* 9 */
407 ACL_ATTR_RAW_USER, /* 10 */
408 ACL_ATTR_RAW_PASSWORD, /* 11 */
409 ACL_ATTR_USER_ISMEMBER, /* 12 */
410 ACL_ATTR_DATABASE, /* 13 */
411 ACL_ATTR_DBTYPE, /* 14 */
412 ACL_ATTR_DBNAME, /* 15 */
413 ACL_ATTR_DATABASE_URL, /* 16 */
414 ACL_ATTR_METHOD, /* 17 */
415 ACL_ATTR_AUTHTYPE, /* 18 */
416 ACL_ATTR_AUTHORIZATION, /* 19 */
417 ACL_ATTR_PARSEFN, /* 20 */
418 ACL_ATTR_ATTRIBUTE, /* 21 */
419 ACL_ATTR_GETTERFN, /* 22 */
420 ACL_ATTR_IP, /* 23 */
421 ACL_ATTR_DNS, /* 24 */
422 ACL_ATTR_MODULE, /* 25 */
423 ACL_ATTR_MODULEFUNC, /* 26 */
424 ACL_ATTR_GROUPS, /* 27 */
425 ACL_ATTR_IS_VALID_PASSWORD, /* 28 */
426 ACL_ATTR_CERT2USER, /* 29 */
427 ACL_ATTR_USER_CERT, /* 30 */
428 ACL_ATTR_PROMPT, /* 31 */
429 ACL_ATTR_TIME, /* 32 */
430 ACL_ATTR_USERS_GROUP, /* 33 */
431 ACL_ATTR_SESSION, /* 34 */
432 ACL_ATTR_REQUEST, /* 35 */
433 ACL_ATTR_ERROR, /* 36 */
434 ACL_ATTR_PROGRAMS, /* 37 */
435 ACL_ATTR_ACCEL_AUTH, /* 38 */
436 ACL_ATTR_WWW_AUTH_PROMPT, /* 39 */
437 ACL_ATTR_OWNER, /* 40 */
438 ACL_ATTR_IS_OWNER, /* 41 */
439 ACL_ATTR_CACHED_USER, /* 42 */
440 ACL_ATTR_USER_EXISTS /* 43 */
441 };
442 #endif
443
444
445 #define ACL_DBTYPE_LDAP "ldap"
446
447 #define METHOD_DEFAULT "default"
448
449 /* Errors must be < 0 */
450 #define ACL_RES_ERROR -1
451
452 /* LAS return codes - Must all be negative numbers */
453 #define LAS_EVAL_TRUE -1
454 #define LAS_EVAL_FALSE -2
455 #define LAS_EVAL_DECLINE -3
456 #define LAS_EVAL_FAIL -4
457 #define LAS_EVAL_INVALID -5
458 #define LAS_EVAL_NEED_MORE_INFO -6
459
460 /* Max pathlength. Intended to match REQ_MAX_LEN */
461 #define ACL_PATH_MAX 4096
462
463 NSPR_END_EXTERN_C
464
465 #endif /* !PUBLIC_NSACL_ACLDEF_H */