Print this page
Add libuserdefs and use in cmd/{oamuser,passwd}
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/userdefs.h
+++ new/usr/src/head/userdefs.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 + * Copyright 2016 Gordon W. Ross
24 + *
23 25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28
27 29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 30 /* All Rights Reserved */
29 31
30 32
31 33 #ifndef _USERDEFS_H
32 34 #define _USERDEFS_H
33 35
34 -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7.1.1 */
35 -
36 36 #include <project.h>
37 +#include <stdio_tag.h>
37 38
38 39 #ifdef __cplusplus
39 40 extern "C" {
40 41 #endif
41 42
42 43 /*
43 44 * The definitions in this file are local to the OA&M subsystem. General
44 45 * use is not encouraged.
46 + *
47 + * Default values are taken from (in precedence order)
48 + * /etc/default/add{user,role}
49 + * /usr/sadm/defadd{user,role}
50 + * (compiled-in values)
51 + *
52 + * Note that the "old" default locations may be used as a
53 + * "vendor" (or distro.) override of the compiled-in defaults.
54 + * If an administrator runs "useradd -D ...", those values are
55 + * stored in /etc/default/add*, which overrides all others.
45 56 */
46 57
47 -/* User/group default values */
48 -#define DEFGID 99 /* max reserved group id */
49 -#define DEFRID 99
50 -#define DEFPROJ 3
51 -#define DEFPROJNAME "default"
52 -#define DEFGROUP 1
53 -#define DEFGNAME "other"
54 -#define DEFPARENT "/home"
55 -#define DEFSKL "/etc/skel"
56 -#define DEFSHL "/bin/sh"
57 -#define DEFROLESHL "/bin/pfsh"
58 -#define DEFINACT 0
59 -#define DEFEXPIRE ""
60 -#define DEFAUTH ""
61 -#define DEFPROF ""
62 -#define DEFROLEPROF "All"
63 -#define DEFROLE ""
64 -#define DEFLIMPRIV ""
65 -#define DEFDFLTPRIV ""
66 -#define DEFLOCK_AFTER_RETRIES ""
58 +/* Defaults files */
59 +#define DEFFILE "/etc/default/adduser"
60 +#define DEFROLEFILE "/etc/default/addrole"
67 61
62 +/* Old defaults files */
63 +#define ODEFFILE "/usr/sadm/defadduser"
64 +#define ODEFROLEFILE "/usr/sadm/defaddrole"
65 +
66 +#define GROUP "/etc/group"
67 +
68 +/* various limits */
69 +#define MAXGLEN 9 /* max length of group name */
70 +#define MAXDLEN 80 /* max length of a date string */
71 +
68 72 /* Defaults file keywords */
69 73 #define RIDSTR "defrid="
70 74 #define GIDSTR "defgroup="
71 75 #define GNAMSTR "defgname="
72 76 #define PARSTR "defparent="
73 77 #define SKLSTR "defskel="
74 78 #define SHELLSTR "defshell="
75 79 #define INACTSTR "definact="
76 80 #define EXPIRESTR "defexpire="
77 81 #define AUTHSTR "defauthorization="
78 82 #define PROFSTR "defprofile="
79 83 #define ROLESTR "defrole="
80 84 #define PROJSTR "defproj="
81 85 #define PROJNMSTR "defprojname="
82 86 #define LIMPRSTR "deflimitpriv="
83 87 #define DFLTPRSTR "defdefaultpriv="
84 88 #define FHEADER "# Default values for useradd. Changed "
85 89 #define FHEADER_ROLE "# Default values for roleadd. Changed "
86 90 #define LOCK_AFTER_RETRIESSTR "deflock_after_retries="
87 91
88 -/* Defaults file */
89 -#define DEFFILE "/usr/sadm/defadduser"
90 -#define DEFROLEFILE "/usr/sadm/defaddrole"
91 -#define GROUP "/etc/group"
92 -
93 -/* various limits */
94 -#define MAXGLEN 9 /* max length of group name */
95 -#define MAXDLEN 80 /* max length of a date string */
96 -
97 92 /* defaults structure */
98 93 struct userdefs {
99 94 int defrid; /* highest reserved uid */
100 95 int defgroup; /* default group id */
101 96 char *defgname; /* default group name */
102 97 char *defparent; /* default base directory for new logins */
103 98 char *defskel; /* default skel directory */
104 99 char *defshell; /* default shell */
105 100 int definact; /* default inactive */
106 101 char *defexpire; /* default expire date */
107 102 char *defauth; /* default authorization */
108 103 char *defprof; /* default profile */
109 104 char *defrole; /* default role */
110 105 projid_t defproj; /* default project id */
111 106 char *defprojname; /* default project name */
112 107 char *deflimpriv; /* default limitpriv */
113 108 char *defdfltpriv; /* default defaultpriv */
114 109 char *deflock_after_retries; /* default lock_after_retries */
115 -
116 110 };
117 111
112 +extern struct userdefs *_get_userdefs(void);
113 +extern struct userdefs *_get_roledefs(void);
114 +
115 +extern void fread_defs(FILE *fp, struct userdefs *, boolean_t);
116 +extern int fwrite_roledefs(struct __FILE *, struct userdefs *);
117 +extern int fwrite_userdefs(struct __FILE *, struct userdefs *);
118 +
119 +extern char *userdef_get_by_uakey(struct userdefs *, const char *);
120 +void userdef_set_by_uakey(struct userdefs *, const char *, char *);
121 +
122 +/*
123 + * User/group default values
124 + * These are constants _only_ when compiling libuserdefs
125 + */
126 +#ifdef _USERDEFS_INTERNAL
127 +#define DEFRID 99 /* max reserved group id */
128 +#define DEFGROUP 1
129 +#define DEFGNAME "other"
130 +#define DEFPARENT "/home"
131 +#define DEFSKL "/etc/skel"
132 +#define DEFSHL "/bin/sh"
133 +#define DEFROLESHL "/bin/pfsh"
134 +#define DEFINACT 0
135 +#define DEFEXPIRE ""
136 +#define DEFAUTH ""
137 +#define DEFPROF ""
138 +#define DEFROLEPROF "All"
139 +#define DEFROLE ""
140 +#define DEFPROJ 3
141 +#define DEFPROJNAME "default"
142 +#define DEFLIMPRIV ""
143 +#define DEFDFLTPRIV ""
144 +#define DEFLOCK_AFTER_RETRIES ""
145 +#else /* _USERDEFS_INTERNAL */
146 +/* Get these from libuserdefs */
147 +#define DEFRID (_get_userdefs()->defrid)
148 +#define DEFGROUP (_get_userdefs()->defgroup)
149 +#define DEFGNAME (_get_userdefs()->defgname)
150 +#define DEFPARENT (_get_userdefs()->defparent)
151 +#define DEFSKL (_get_userdefs()->defskel)
152 +#define DEFSHL (_get_userdefs()->defshell)
153 +#define DEFROLESHL (_get_roledefs()->defshell) /* ROLE */
154 +#define DEFINACT (_get_userdefs()->definact)
155 +#define DEFEXPIRE (_get_userdefs()->defexpire)
156 +#define DEFAUTH (_get_userdefs()->defauth)
157 +#define DEFPROF (_get_userdefs()->defprof
158 +#define DEFROLEPROF (_get_roledefs()->defprof) /* ROLE */
159 +#define DEFROLE (_get_userdefs()->defrole)
160 +#define DEFPROJ (_get_userdefs()->defproj)
161 +#define DEFPROJNAME (_get_userdefs()->defprogname)
162 +#define DEFLIMPRIV (_get_userdefs()->deflimpriv)
163 +#define DEFDFLTPRIV (_get_userdefs()->defdfltpriv)
164 +#define DEFLOCK_AFTER_RETRIES (_get_userdefs()->deflock_after_retries)
165 +#endif /* _USERDEFS_INTERNAL */
166 +
167 +/* DEFGID is an alias for DEFRID. Misleading... (!= DEFGROUP) */
168 +#define DEFGID DEFRID /* XXX delete this? */
169 +
118 170 /* exit() values for user/group commands */
119 171
120 172 /* Everything succeeded */
121 173 #define EX_SUCCESS 0
122 174
123 175 /* No permission */
124 176 #define EX_NO_PERM 1
125 177
126 178 /* Command syntax error */
127 179 #define EX_SYNTAX 2
128 180
129 181 /* Invalid argument given */
130 182 #define EX_BADARG 3
131 183
132 184 /* A gid or uid already exists */
133 185 #define EX_ID_EXISTS 4
134 186
135 187 /* PASSWD and SHADOW are inconsistent with each other */
136 188 #define EX_INCONSISTENT 5
137 189
138 190 /* A group or user name doesn't exist */
139 191 #define EX_NAME_NOT_EXIST 6
140 192
141 193 /* GROUP, PASSWD, or SHADOW file missing */
142 194 #define EX_MISSING 7
143 195
144 196 /* GROUP, PASSWD, or SHAWOW file is busy */
145 197 #define EX_BUSY 8
146 198
147 199 /* A group or user name already exists */
148 200 #define EX_NAME_EXISTS 9
149 201
150 202 /* Unable to update GROUP, PASSWD, or SHADOW file */
151 203 #define EX_UPDATE 10
152 204
153 205 /* Not enough space */
154 206 #define EX_NOSPACE 11
155 207
156 208 /* Unable to create/remove/move home directory */
157 209 #define EX_HOMEDIR 12
158 210
159 211 /* new login already in use */
160 212 #define EX_NL_USED 13
161 213
162 214 /* Unexpected failure */
163 215 #define EX_FAILURE 14
164 216
165 217 /* A user name is in a non-local name service */
166 218 #define EX_NOT_LOCAL 15
167 219
168 220 #ifdef __cplusplus
169 221 }
170 222 #endif
171 223
172 224 #endif /* _USERDEFS_H */
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX