xref: /titanic_51/usr/src/cmd/auths/auths.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #include <stdio.h>
30*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
31*7c478bd9Sstevel@tonic-gate #include <unistd.h>
32*7c478bd9Sstevel@tonic-gate #include <pwd.h>
33*7c478bd9Sstevel@tonic-gate #include <string.h>
34*7c478bd9Sstevel@tonic-gate #include <deflt.h>
35*7c478bd9Sstevel@tonic-gate #include <libintl.h>
36*7c478bd9Sstevel@tonic-gate #include <locale.h>
37*7c478bd9Sstevel@tonic-gate #include <user_attr.h>
38*7c478bd9Sstevel@tonic-gate #include <prof_attr.h>
39*7c478bd9Sstevel@tonic-gate #include <auth_attr.h>
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #define	ALL_AUTHS	"All"
43*7c478bd9Sstevel@tonic-gate #define	ALL_SUN_AUTHS	"solaris.*"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #define	EXIT_OK		0
46*7c478bd9Sstevel@tonic-gate #define	EXIT_FATAL	1
47*7c478bd9Sstevel@tonic-gate #define	EXIT_NON_FATAL	2
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #ifndef	TEXT_DOMAIN			/* Should be defined by cc -D */
50*7c478bd9Sstevel@tonic-gate #define	TEXT_DOMAIN	"SYS_TEST"
51*7c478bd9Sstevel@tonic-gate #endif
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate #define	PROFLIST_SEP	","
54*7c478bd9Sstevel@tonic-gate #define	AUTH_SEP	","
55*7c478bd9Sstevel@tonic-gate #define	MAXAUTHS	4096
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate static int show_auths(char *, char **, int, int);
59*7c478bd9Sstevel@tonic-gate static int list_auths(userattr_t *, char **, int *);
60*7c478bd9Sstevel@tonic-gate static char *get_default_auths(char **, int *);
61*7c478bd9Sstevel@tonic-gate static void getProfiles(char *, char **, int *, char **, int *);
62*7c478bd9Sstevel@tonic-gate static void add_auths(char *, char **, int *);
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate static char *progname = "auths";
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate int
69*7c478bd9Sstevel@tonic-gate main(int argc, char *argv[])
70*7c478bd9Sstevel@tonic-gate {
71*7c478bd9Sstevel@tonic-gate 	int		status = EXIT_OK;
72*7c478bd9Sstevel@tonic-gate 	char		*defauths[MAXAUTHS];
73*7c478bd9Sstevel@tonic-gate 	int		defauth_cnt = 0;
74*7c478bd9Sstevel@tonic-gate 	int		i;
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate 	(void) setlocale(LC_ALL, "");
77*7c478bd9Sstevel@tonic-gate 	(void) textdomain(TEXT_DOMAIN);
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate 	(void) get_default_auths(defauths, &defauth_cnt);
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate 	switch (argc) {
82*7c478bd9Sstevel@tonic-gate 	case 1:
83*7c478bd9Sstevel@tonic-gate 		status = show_auths(NULL, defauths, defauth_cnt, 0);
84*7c478bd9Sstevel@tonic-gate 		break;
85*7c478bd9Sstevel@tonic-gate 	case 2:
86*7c478bd9Sstevel@tonic-gate 		status = show_auths(argv[argc-1], defauths, defauth_cnt, 0);
87*7c478bd9Sstevel@tonic-gate 		break;
88*7c478bd9Sstevel@tonic-gate 	default:
89*7c478bd9Sstevel@tonic-gate 		while (*++argv) {
90*7c478bd9Sstevel@tonic-gate 			status = show_auths(*argv, defauths, defauth_cnt, 1);
91*7c478bd9Sstevel@tonic-gate 			if (status == EXIT_FATAL) {
92*7c478bd9Sstevel@tonic-gate 				break;
93*7c478bd9Sstevel@tonic-gate 			}
94*7c478bd9Sstevel@tonic-gate 		}
95*7c478bd9Sstevel@tonic-gate 		break;
96*7c478bd9Sstevel@tonic-gate 	}
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 	/* free memory allocated for default authorizations */
99*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < defauth_cnt; i++) {
100*7c478bd9Sstevel@tonic-gate 		free(defauths[i]);
101*7c478bd9Sstevel@tonic-gate 	}
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate 	status = (status == EXIT_OK) ? status : EXIT_FATAL;
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 	return (status);
106*7c478bd9Sstevel@tonic-gate }
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate static int
110*7c478bd9Sstevel@tonic-gate show_auths(char *username, char **defauths, int defauth_cnt, int print_name)
111*7c478bd9Sstevel@tonic-gate {
112*7c478bd9Sstevel@tonic-gate 	int		status = EXIT_OK;
113*7c478bd9Sstevel@tonic-gate 	struct passwd	*pw;
114*7c478bd9Sstevel@tonic-gate 	userattr_t	*user;
115*7c478bd9Sstevel@tonic-gate 	char		*userauths[MAXAUTHS];
116*7c478bd9Sstevel@tonic-gate 	int		userauth_cnt = 0, old_userauth_cnt;
117*7c478bd9Sstevel@tonic-gate 	int		i, j, have_allauths, duplicate;
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate 	if (username == NULL) {
120*7c478bd9Sstevel@tonic-gate 		if ((pw = getpwuid(getuid())) == NULL) {
121*7c478bd9Sstevel@tonic-gate 			status = EXIT_NON_FATAL;
122*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr, "%s: ", progname);
123*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr, gettext("No passwd entry\n"));
124*7c478bd9Sstevel@tonic-gate 			return (status);
125*7c478bd9Sstevel@tonic-gate 		}
126*7c478bd9Sstevel@tonic-gate 		username = pw->pw_name;
127*7c478bd9Sstevel@tonic-gate 	} else if ((pw = getpwnam(username)) == NULL) {
128*7c478bd9Sstevel@tonic-gate 		status = EXIT_NON_FATAL;
129*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "%s: %s : ", progname, username);
130*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, gettext("No such user\n"));
131*7c478bd9Sstevel@tonic-gate 		return (status);
132*7c478bd9Sstevel@tonic-gate 	}
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate 	have_allauths = 0;
135*7c478bd9Sstevel@tonic-gate 	if (username != NULL) {
136*7c478bd9Sstevel@tonic-gate 		/* if ALL_AUTHS is default, don't need to look at other auths */
137*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < defauth_cnt; i++) {
138*7c478bd9Sstevel@tonic-gate 			if (strcmp(defauths[i], ALL_AUTHS) == 0) {
139*7c478bd9Sstevel@tonic-gate 				have_allauths = 1;
140*7c478bd9Sstevel@tonic-gate 				break;
141*7c478bd9Sstevel@tonic-gate 			}
142*7c478bd9Sstevel@tonic-gate 		}
143*7c478bd9Sstevel@tonic-gate 		if (have_allauths) {
144*7c478bd9Sstevel@tonic-gate 			status = EXIT_OK;
145*7c478bd9Sstevel@tonic-gate 		} else if ((user = getusernam(username)) != NULL) {
146*7c478bd9Sstevel@tonic-gate 			status = list_auths(user, userauths, &userauth_cnt);
147*7c478bd9Sstevel@tonic-gate 			/* check if any profiles have ALL_AUTHS */
148*7c478bd9Sstevel@tonic-gate 			for (i = 0; i < userauth_cnt; i++) {
149*7c478bd9Sstevel@tonic-gate 				if (strcmp(userauths[i], ALL_AUTHS) == 0) {
150*7c478bd9Sstevel@tonic-gate 					have_allauths = 1;
151*7c478bd9Sstevel@tonic-gate 					break;
152*7c478bd9Sstevel@tonic-gate 				}
153*7c478bd9Sstevel@tonic-gate 			}
154*7c478bd9Sstevel@tonic-gate 		}
155*7c478bd9Sstevel@tonic-gate 		if ((defauth_cnt + userauth_cnt) == 0) {
156*7c478bd9Sstevel@tonic-gate 			status = EXIT_NON_FATAL;
157*7c478bd9Sstevel@tonic-gate 		}
158*7c478bd9Sstevel@tonic-gate 	}
159*7c478bd9Sstevel@tonic-gate 	if (status == EXIT_NON_FATAL) {
160*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "%s: %s : ", progname, username);
161*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, gettext("No authorizations\n"));
162*7c478bd9Sstevel@tonic-gate 	} else {
163*7c478bd9Sstevel@tonic-gate 		if (print_name) {
164*7c478bd9Sstevel@tonic-gate 			(void) printf("%s : ", username);
165*7c478bd9Sstevel@tonic-gate 		}
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate 		if (have_allauths) {
168*7c478bd9Sstevel@tonic-gate 			(void) printf("%s\n", ALL_SUN_AUTHS);
169*7c478bd9Sstevel@tonic-gate 		} else {
170*7c478bd9Sstevel@tonic-gate 			/*
171*7c478bd9Sstevel@tonic-gate 			 * combine the user auths and default auths,
172*7c478bd9Sstevel@tonic-gate 			 * and eliminate duplicates from the two
173*7c478bd9Sstevel@tonic-gate 			 */
174*7c478bd9Sstevel@tonic-gate 			old_userauth_cnt = userauth_cnt;
175*7c478bd9Sstevel@tonic-gate 			for (i = 0; i < defauth_cnt; i++) {
176*7c478bd9Sstevel@tonic-gate 				duplicate = 0;
177*7c478bd9Sstevel@tonic-gate 				for (j = 0; j < old_userauth_cnt; j++) {
178*7c478bd9Sstevel@tonic-gate 					if (strcmp(userauths[j], defauths[i]) ==
179*7c478bd9Sstevel@tonic-gate 					    0) {
180*7c478bd9Sstevel@tonic-gate 						duplicate = 1;
181*7c478bd9Sstevel@tonic-gate 						break;
182*7c478bd9Sstevel@tonic-gate 					}
183*7c478bd9Sstevel@tonic-gate 				}
184*7c478bd9Sstevel@tonic-gate 				if (!duplicate) {
185*7c478bd9Sstevel@tonic-gate 					userauths[userauth_cnt] =
186*7c478bd9Sstevel@tonic-gate 					    strdup(defauths[i]);
187*7c478bd9Sstevel@tonic-gate 					userauth_cnt++;
188*7c478bd9Sstevel@tonic-gate 				}
189*7c478bd9Sstevel@tonic-gate 			}
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate 			/* print out the auths */
192*7c478bd9Sstevel@tonic-gate 			for (i = 0; i < (userauth_cnt - 1); i++) {
193*7c478bd9Sstevel@tonic-gate 				(void) printf("%s,", userauths[i]);
194*7c478bd9Sstevel@tonic-gate 			}
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate 			/* print out the last entry, without the comma */
197*7c478bd9Sstevel@tonic-gate 			(void) printf("%s\n", userauths[userauth_cnt - 1]);
198*7c478bd9Sstevel@tonic-gate 		}
199*7c478bd9Sstevel@tonic-gate 	}
200*7c478bd9Sstevel@tonic-gate 
201*7c478bd9Sstevel@tonic-gate 	/* free memory allocated for authorizations */
202*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < userauth_cnt; i++) {
203*7c478bd9Sstevel@tonic-gate 		free(userauths[i]);
204*7c478bd9Sstevel@tonic-gate 	}
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate 	return (status);
207*7c478bd9Sstevel@tonic-gate }
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate static int
211*7c478bd9Sstevel@tonic-gate list_auths(userattr_t *user, char **authArray, int *authcnt)
212*7c478bd9Sstevel@tonic-gate {
213*7c478bd9Sstevel@tonic-gate 	int		status = EXIT_OK;
214*7c478bd9Sstevel@tonic-gate 	char		*authlist = NULL;
215*7c478bd9Sstevel@tonic-gate 	char		*proflist = NULL;
216*7c478bd9Sstevel@tonic-gate 	char		*profArray[MAXPROFS];
217*7c478bd9Sstevel@tonic-gate 	int		profcnt = 0;
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate 	authlist = kva_match(user->attr, USERATTR_AUTHS_KW);
220*7c478bd9Sstevel@tonic-gate 	if (authlist != NULL) {
221*7c478bd9Sstevel@tonic-gate 		add_auths(authlist, authArray, authcnt);
222*7c478bd9Sstevel@tonic-gate 	}
223*7c478bd9Sstevel@tonic-gate 	if ((proflist = kva_match(user->attr, USERATTR_PROFILES_KW)) == NULL) {
224*7c478bd9Sstevel@tonic-gate 		if (authcnt == 0) {
225*7c478bd9Sstevel@tonic-gate 			status = EXIT_NON_FATAL;
226*7c478bd9Sstevel@tonic-gate 		}
227*7c478bd9Sstevel@tonic-gate 	} else {
228*7c478bd9Sstevel@tonic-gate 		getProfiles(proflist, profArray, &profcnt,
229*7c478bd9Sstevel@tonic-gate 		    authArray, authcnt);
230*7c478bd9Sstevel@tonic-gate 		free_proflist(profArray, profcnt);
231*7c478bd9Sstevel@tonic-gate 	}
232*7c478bd9Sstevel@tonic-gate 	if (authcnt == 0) {
233*7c478bd9Sstevel@tonic-gate 		status = EXIT_NON_FATAL;
234*7c478bd9Sstevel@tonic-gate 	}
235*7c478bd9Sstevel@tonic-gate 	free_userattr(user);
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate 	return (status);
238*7c478bd9Sstevel@tonic-gate }
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate static char *
242*7c478bd9Sstevel@tonic-gate get_default_auths(char **authArray, int *authcnt)
243*7c478bd9Sstevel@tonic-gate {
244*7c478bd9Sstevel@tonic-gate 	char *auths = NULL;
245*7c478bd9Sstevel@tonic-gate 	char *profs = NULL;
246*7c478bd9Sstevel@tonic-gate 	char *profArray[MAXPROFS];
247*7c478bd9Sstevel@tonic-gate 	int profcnt = 0;
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate 	if (defopen(AUTH_POLICY) == NULL) {
250*7c478bd9Sstevel@tonic-gate 		auths = defread(DEF_AUTH);
251*7c478bd9Sstevel@tonic-gate 		if (auths != NULL) {
252*7c478bd9Sstevel@tonic-gate 			add_auths(auths, authArray, authcnt);
253*7c478bd9Sstevel@tonic-gate 		}
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate 		/* get authorizations from default profiles */
256*7c478bd9Sstevel@tonic-gate 		profs = defread(DEF_PROF);
257*7c478bd9Sstevel@tonic-gate 		if (profs != NULL) {
258*7c478bd9Sstevel@tonic-gate 			getProfiles(profs, profArray, &profcnt,
259*7c478bd9Sstevel@tonic-gate 			    authArray, authcnt);
260*7c478bd9Sstevel@tonic-gate 			free_proflist(profArray, profcnt);
261*7c478bd9Sstevel@tonic-gate 		}
262*7c478bd9Sstevel@tonic-gate 	}
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate 	return (auths);
265*7c478bd9Sstevel@tonic-gate }
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate void
268*7c478bd9Sstevel@tonic-gate add_auths(char *auths, char **authArray, int *authcnt)
269*7c478bd9Sstevel@tonic-gate {
270*7c478bd9Sstevel@tonic-gate 	char	*authname, *lasts, *real_authname;
271*7c478bd9Sstevel@tonic-gate 	int	i;
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate 	for (authname = (char *)strtok_r(auths, AUTH_SEP, &lasts);
274*7c478bd9Sstevel@tonic-gate 	    authname != NULL;
275*7c478bd9Sstevel@tonic-gate 	    authname = (char *)strtok_r(NULL, AUTH_SEP, &lasts)) {
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate 		if ((strcmp(authname, KV_WILDCARD) == 0) ||
278*7c478bd9Sstevel@tonic-gate 		    (strcmp(authname, ALL_SUN_AUTHS) == 0)) {
279*7c478bd9Sstevel@tonic-gate 			real_authname = ALL_AUTHS;
280*7c478bd9Sstevel@tonic-gate 		} else {
281*7c478bd9Sstevel@tonic-gate 			real_authname = authname;
282*7c478bd9Sstevel@tonic-gate 		}
283*7c478bd9Sstevel@tonic-gate 
284*7c478bd9Sstevel@tonic-gate 		/* check to see if authorization is already in list */
285*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < *authcnt; i++) {
286*7c478bd9Sstevel@tonic-gate 			if (strcmp(real_authname, authArray[i]) == 0) {
287*7c478bd9Sstevel@tonic-gate 				break;	/* already in list */
288*7c478bd9Sstevel@tonic-gate 			}
289*7c478bd9Sstevel@tonic-gate 		}
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate 		/* not in list, add it in */
292*7c478bd9Sstevel@tonic-gate 		if (i == *authcnt) {
293*7c478bd9Sstevel@tonic-gate 			authArray[i] = strdup(real_authname);
294*7c478bd9Sstevel@tonic-gate 			*authcnt = i + 1;
295*7c478bd9Sstevel@tonic-gate 		}
296*7c478bd9Sstevel@tonic-gate 	}
297*7c478bd9Sstevel@tonic-gate 
298*7c478bd9Sstevel@tonic-gate }
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate static void
301*7c478bd9Sstevel@tonic-gate getProfiles(char *profiles, char **profArray, int *profcnt,
302*7c478bd9Sstevel@tonic-gate 	char **authArray, int *authcnt)
303*7c478bd9Sstevel@tonic-gate {
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate 	char		*prof;
306*7c478bd9Sstevel@tonic-gate 	char		*lasts;
307*7c478bd9Sstevel@tonic-gate 	profattr_t	*pa;
308*7c478bd9Sstevel@tonic-gate 	char		*auths;
309*7c478bd9Sstevel@tonic-gate 	int		i;
310*7c478bd9Sstevel@tonic-gate 
311*7c478bd9Sstevel@tonic-gate 	for (prof = (char *)strtok_r(profiles, PROFLIST_SEP, &lasts);
312*7c478bd9Sstevel@tonic-gate 	    prof != NULL;
313*7c478bd9Sstevel@tonic-gate 	    prof = (char *)strtok_r(NULL, PROFLIST_SEP, &lasts)) {
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate 		getproflist(prof, profArray, profcnt);
316*7c478bd9Sstevel@tonic-gate 	}
317*7c478bd9Sstevel@tonic-gate 
318*7c478bd9Sstevel@tonic-gate 	/* get authorizations from list of profiles */
319*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < *profcnt; i++) {
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate 		if ((pa = getprofnam(profArray[i])) == NULL) {
322*7c478bd9Sstevel@tonic-gate 			/*
323*7c478bd9Sstevel@tonic-gate 			 *  this should never happen.
324*7c478bd9Sstevel@tonic-gate 			 *  unless the database has an undefined profile
325*7c478bd9Sstevel@tonic-gate 			 */
326*7c478bd9Sstevel@tonic-gate 			continue;
327*7c478bd9Sstevel@tonic-gate 		}
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate 		/* get auths this profile */
330*7c478bd9Sstevel@tonic-gate 		auths = kva_match(pa->attr, PROFATTR_AUTHS_KW);
331*7c478bd9Sstevel@tonic-gate 		if (auths != NULL) {
332*7c478bd9Sstevel@tonic-gate 			add_auths(auths, authArray, authcnt);
333*7c478bd9Sstevel@tonic-gate 		}
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate 		free_profattr(pa);
336*7c478bd9Sstevel@tonic-gate 	}
337*7c478bd9Sstevel@tonic-gate }
338