xref: /titanic_51/usr/src/head/user_attr.h (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_USER_ATTR_H
27 #define	_USER_ATTR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 
36 #include <sys/types.h>
37 #include <secdb.h>
38 
39 
40 struct __FILE;		/* structure tag for type FILE defined in stdio.h */
41 
42 /*
43  * Some macros used internally by the nsswitch code
44  */
45 #define	USERATTR_FILENAME		"/etc/user_attr"
46 #define	USERATTR_DB_NAME		"user_attr.org_dir"
47 #define	USERATTR_DB_NCOL		5	/* total columns */
48 #define	USERATTR_DB_NKEYCOL		2	/* total searchable columns */
49 #define	USERATTR_DB_TBL			"user_attr_tbl"
50 #define	USERATTR_NAME_DEFAULT_KW	"nobody"
51 
52 #define	USERATTR_COL0_KW		"name"
53 #define	USERATTR_COL1_KW		"qualifier"
54 #define	USERATTR_COL2_KW		"res1"
55 #define	USERATTR_COL3_KW		"res2"
56 #define	USERATTR_COL4_KW		"attr"
57 
58 #define	DEF_LIMITPRIV			"PRIV_LIMIT="
59 #define	DEF_DFLTPRIV			"PRIV_DEFAULT="
60 
61 /*
62  * indices of searchable columns
63  */
64 #define	USERATTR_KEYCOL0		0	/* name */
65 #define	USERATTR_KEYCOL1		1	/* qualifier */
66 
67 /*
68  * Key words used in the user_attr database
69  */
70 #define	USERATTR_LOCK_KW		"lock"
71 #define	USERATTR_LOCK_LOCKED_KW		"locked"
72 #define	USERATTR_LOCK_OPEN_KW		"open"
73 #define	USERATTR_LOCK_FIXED_KW		"fixed"
74 #define	USERATTR_GEN_KW			"gen"
75 #define	USERATTR_GEN_AUTOMATIC_KW	"automatic"
76 #define	USERATTR_GEN_MANUAL_KW		"manual"
77 #define	USERATTR_GEN_SYSDEF_KW		"sysdef"
78 #define	USERATTR_PROFILES_KW		"profiles"
79 #define	USERATTR_PROFILES_NONE_KW	"none"
80 #define	USERATTR_ROLES_KW		"roles"
81 #define	USERATTR_ROLES_NONE_KW		"none"
82 #define	USERATTR_DEFAULTPROJ_KW		"project"
83 #define	USERATTR_IDLETIME_KW		"idletime"
84 #define	USERATTR_IDLECMD_KW		"idlecmd"
85 #define	USERATTR_IDLECMD_LOCK_KW	"lock"
86 #define	USERATTR_IDLECMD_LOGOUT_KW	"logout"
87 #define	USERATTR_TYPE_KW		"type"
88 #define	USERATTR_TYPE_NORMAL_KW		"normal"
89 #define	USERATTR_TYPE_ADMIN_KW		"admin"
90 #define	USERATTR_TYPE_NONADMIN_KW	"role"
91 #define	USERATTR_AUTHS_KW		"auths"
92 #define	USERATTR_LIMPRIV_KW		"limitpriv"
93 #define	USERATTR_DFLTPRIV_KW		"defaultpriv"
94 #define	USERATTR_LOCK_AFTER_RETRIES_KW	"lock_after_retries"
95 #define	USERATTR_CLEARANCE		"clearance"
96 #define	USERATTR_LABELVIEW		"labelview"
97 #define	USERATTR_LABELVIEW_EXTERNAL	"external"
98 #define	USERATTR_LABELVIEW_HIDESL	"hidesl"
99 #define	USERATTR_HIDESL			USERATTR_LABELVIEW_HIDESL
100 #define	USERATTR_LABELVIEW_INTERNAL	"internal"
101 #define	USERATTR_LABELVIEW_SHOWSL	"showsl"
102 #define	USERATTR_LABELTRANS		"labeltrans"
103 #define	USERATTR_LOCK_NO		"no"
104 #define	USERATTR_LOCK_YES		"yes"
105 #define	USERATTR_MINLABEL		"min_label"
106 #define	USERATTR_PASSWD			"password"
107 #define	USERATTR_PASSWD_AUTOMATIC	"automatic"
108 #define	USERATTR_PASSWD_MANUAL		"manual"
109 #define	USERATTR_TYPE_ROLE		USERATTR_TYPE_NONADMIN_KW
110 
111 
112 /*
113  * Nsswitch representation of user attributes.
114  */
115 typedef struct userstr_s {
116 	char   *name;		/* user name */
117 	char   *qualifier;	/* reserved for future use */
118 	char   *res1;		/* reserved for future use */
119 	char   *res2;		/* reserved for future use */
120 	char   *attr;		/* string of key-value pair attributes */
121 } userstr_t;
122 
123 /*
124  * API representation of user attributes.
125  */
126 typedef struct userattr_s {
127 	char   *name;		/* user name */
128 	char   *qualifier;	/* reserved for future use */
129 	char   *res1;		/* reserved for future use */
130 	char   *res2;		/* reserved for future use */
131 	kva_t  *attr;		/* array of key-value pair attributes */
132 } userattr_t;
133 
134 #ifdef	__STDC__
135 extern userattr_t *getusernam(const char *);
136 extern userattr_t *getuseruid(uid_t uid);
137 extern userattr_t *getuserattr(void);
138 extern userattr_t *fgetuserattr(struct __FILE *);
139 extern void setuserattr(void);
140 extern void enduserattr(void);
141 extern void free_userattr(userattr_t *);
142 
143 #else				/* not __STDC__ */
144 
145 extern userattr_t *getusernam();
146 extern userattr_t *getuseruid();
147 extern userattr_t *getuserattr();
148 extern userattr_t *fgetuserattr();
149 extern void setuserattr();
150 extern void enduserattr();
151 extern void free_userattr();
152 #endif
153 
154 #ifdef	__cplusplus
155 }
156 #endif
157 
158 #endif	/* _USER_ATTR_H */
159