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