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