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