xref: /titanic_44/usr/src/head/secdb.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SECDB_H
28 #define	_SECDB_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 #define	DEFAULT_POLICY		"solaris"
38 #define	SUSER_POLICY		"suser"		/* fallback: old policy */
39 
40 #define	KV_ACTION		"act"
41 #define	KV_COMMAND		"cmd"
42 #define	KV_JAVA_CLASS		"java_class"
43 #define	KV_JAVA_METHOD		"java_method"
44 
45 #define	KV_ASSIGN		"="
46 #define	KV_DELIMITER		";"
47 #define	KV_EMPTY		""
48 #define	KV_ESCAPE		'\\'
49 #define	KV_ADD_KEYS		16    /* number of key value pairs to realloc */
50 #define	KV_SPECIAL		"=;:\\";
51 #define	KV_TOKEN_DELIMIT	":"
52 #define	KV_WILDCARD		"*"
53 #define	KV_WILDCHAR		'*'
54 #define	KV_ACTION_WILDCARD	"*;*;*;*;*"
55 
56 #define	KV_FLAG_NONE		0x0000
57 #define	KV_FLAG_REQUIRED	0x0001
58 
59 /*
60  * return status macros for all attribute databases
61  */
62 #define	ATTR_FOUND		0	/* Authoritative found */
63 #define	ATTR_NOT_FOUND		-1	/* Authoritative not found */
64 #define	ATTR_NO_RECOVERY	-2	/* Non-recoverable errors */
65 
66 
67 typedef struct kv_s {
68 	char   *key;
69 	char   *value;
70 } kv_t;					/* A key-value pair */
71 
72 typedef struct kva_s {
73 	int	length;			/* array length */
74 	kv_t    *data;			/* array of key value pairs */
75 } kva_t;				/* Key-value array */
76 
77 
78 #ifdef	__STDC__
79 extern char *kva_match(kva_t *, char *);
80 
81 extern int _auth_match(const char *, const char *);
82 extern char *_argv_to_csl(char **strings);
83 extern char **_csl_to_argv(char *csl);
84 extern char *_do_unescape(char *src);
85 extern void _free_argv(char **p_argv);
86 extern int _get_auth_policy(char **, char **);
87 extern int _insert2kva(kva_t *, char *, char *);
88 extern int _kva2str(kva_t *, char *, int, char *, char *);
89 extern kva_t *_kva_dup(kva_t *);
90 extern void _kva_free(kva_t *);
91 extern kva_t *_new_kva(int size);
92 extern kva_t *_str2kva(char *, char *, char *);
93 
94 #else				/* not __STDC__ */
95 
96 extern char *kva_match();
97 
98 extern int _auth_match();
99 extern char *_argv_to_csl();
100 extern char **_csl_to_argv();
101 extern char *_do_unescape();
102 extern void _free_argv();
103 extern int _get_auth_policy();
104 extern int  _insert2kva();
105 extern int _kva2str();
106 extern kva_t *_kva_dup();
107 extern void _kva_free(kva_t *);
108 extern kva_t *_new_kva();
109 extern int _str2kva();
110 #endif				/* __STDC__ */
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif	/* _SECDB_H */
117