xref: /titanic_53/usr/src/cmd/profiles/profiles.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 <libintl.h>
35*7c478bd9Sstevel@tonic-gate #include <locale.h>
36*7c478bd9Sstevel@tonic-gate #include <deflt.h>
37*7c478bd9Sstevel@tonic-gate #include <user_attr.h>
38*7c478bd9Sstevel@tonic-gate #include <prof_attr.h>
39*7c478bd9Sstevel@tonic-gate #include <exec_attr.h>
40*7c478bd9Sstevel@tonic-gate #include <auth_attr.h>
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #define	EXIT_OK		0
44*7c478bd9Sstevel@tonic-gate #define	EXIT_FATAL	1
45*7c478bd9Sstevel@tonic-gate #define	EXIT_NON_FATAL	2
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #define	MAX_LINE_LEN	80		/* max 80 chars per line of output */
48*7c478bd9Sstevel@tonic-gate #define	TMP_BUF_LEN	2048		/* size of temp string buffer */
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #define	PRINT_DEFAULT	0x0000
51*7c478bd9Sstevel@tonic-gate #define	PRINT_NAME	0x0010
52*7c478bd9Sstevel@tonic-gate #define	PRINT_LONG	0x0020
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #ifndef TEXT_DOMAIN			/* Should be defined by cc -D */
55*7c478bd9Sstevel@tonic-gate #define	TEXT_DOMAIN	"SYS_TEST"
56*7c478bd9Sstevel@tonic-gate #endif
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	PROFLIST_SEP	","
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate static void usage();
62*7c478bd9Sstevel@tonic-gate static int show_profs(char *, int);
63*7c478bd9Sstevel@tonic-gate static int list_profs(userattr_t *, int);
64*7c478bd9Sstevel@tonic-gate static void print_profs_long(char *, void *, int);
65*7c478bd9Sstevel@tonic-gate static void print_profs(char *, char **, int, int);
66*7c478bd9Sstevel@tonic-gate static void format_attr(int *, int, char *);
67*7c478bd9Sstevel@tonic-gate static void getProfiles(char *, char **, int *);
68*7c478bd9Sstevel@tonic-gate static void getDefaultProfiles(char **, int *);
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate static char *progname = "profiles";
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate int
73*7c478bd9Sstevel@tonic-gate main(int argc, char *argv[])
74*7c478bd9Sstevel@tonic-gate {
75*7c478bd9Sstevel@tonic-gate 	extern int	optind;
76*7c478bd9Sstevel@tonic-gate 	register int	c;
77*7c478bd9Sstevel@tonic-gate 	register int	status = EXIT_OK;
78*7c478bd9Sstevel@tonic-gate 	int		print_flag = PRINT_DEFAULT;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate 	(void) setlocale(LC_ALL, "");
81*7c478bd9Sstevel@tonic-gate 	(void) textdomain(TEXT_DOMAIN);
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate 	while ((c = getopt(argc, argv, "l")) != EOF) {
84*7c478bd9Sstevel@tonic-gate 		switch (c) {
85*7c478bd9Sstevel@tonic-gate 		case 'l':
86*7c478bd9Sstevel@tonic-gate 			print_flag |= PRINT_LONG;
87*7c478bd9Sstevel@tonic-gate 			break;
88*7c478bd9Sstevel@tonic-gate 		default:
89*7c478bd9Sstevel@tonic-gate 			usage();
90*7c478bd9Sstevel@tonic-gate 			return (EXIT_FATAL);
91*7c478bd9Sstevel@tonic-gate 		}
92*7c478bd9Sstevel@tonic-gate 	}
93*7c478bd9Sstevel@tonic-gate 	argc -= optind;
94*7c478bd9Sstevel@tonic-gate 	argv += optind;
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate 	if (*argv == NULL) {
97*7c478bd9Sstevel@tonic-gate 		status = show_profs((char *)NULL, print_flag);
98*7c478bd9Sstevel@tonic-gate 	} else {
99*7c478bd9Sstevel@tonic-gate 		do {
100*7c478bd9Sstevel@tonic-gate 			status = show_profs(*argv, print_flag);
101*7c478bd9Sstevel@tonic-gate 			if (status == EXIT_FATAL) {
102*7c478bd9Sstevel@tonic-gate 				break;
103*7c478bd9Sstevel@tonic-gate 			}
104*7c478bd9Sstevel@tonic-gate 		} while (*++argv);
105*7c478bd9Sstevel@tonic-gate 	}
106*7c478bd9Sstevel@tonic-gate 	status = (status == EXIT_OK) ? status : EXIT_FATAL;
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 	return (status);
109*7c478bd9Sstevel@tonic-gate }
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate static int
113*7c478bd9Sstevel@tonic-gate show_profs(char *username, int print_flag)
114*7c478bd9Sstevel@tonic-gate {
115*7c478bd9Sstevel@tonic-gate 	register int		status = EXIT_OK;
116*7c478bd9Sstevel@tonic-gate 	register struct passwd	*pw;
117*7c478bd9Sstevel@tonic-gate 	register userattr_t	*user;
118*7c478bd9Sstevel@tonic-gate 	char			*profArray[MAXPROFS];
119*7c478bd9Sstevel@tonic-gate 	int			profcnt = 0;
120*7c478bd9Sstevel@tonic-gate 	execattr_t		*exec;
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate 	if (username == NULL) {
123*7c478bd9Sstevel@tonic-gate 		if ((pw = getpwuid(getuid())) == NULL) {
124*7c478bd9Sstevel@tonic-gate 			status = EXIT_NON_FATAL;
125*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr, "%s: ", progname);
126*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr, gettext("No passwd entry\n"));
127*7c478bd9Sstevel@tonic-gate 			return (status);
128*7c478bd9Sstevel@tonic-gate 		}
129*7c478bd9Sstevel@tonic-gate 		username = pw->pw_name;
130*7c478bd9Sstevel@tonic-gate 	} else if ((pw = getpwnam(username)) == NULL) {
131*7c478bd9Sstevel@tonic-gate 		status = EXIT_NON_FATAL;
132*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "%s: %s : ", progname, username);
133*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, gettext("No such user\n"));
134*7c478bd9Sstevel@tonic-gate 		return (status);
135*7c478bd9Sstevel@tonic-gate 	}
136*7c478bd9Sstevel@tonic-gate 	if (username != NULL) {
137*7c478bd9Sstevel@tonic-gate 		if ((user = getusernam(username)) != NULL) {
138*7c478bd9Sstevel@tonic-gate 			status = list_profs(user, print_flag);
139*7c478bd9Sstevel@tonic-gate 		} else {
140*7c478bd9Sstevel@tonic-gate 			getDefaultProfiles(profArray, &profcnt);
141*7c478bd9Sstevel@tonic-gate 			if (profcnt == 0) {
142*7c478bd9Sstevel@tonic-gate 				status = EXIT_NON_FATAL;
143*7c478bd9Sstevel@tonic-gate 			} else {
144*7c478bd9Sstevel@tonic-gate 				if (print_flag & PRINT_LONG) {
145*7c478bd9Sstevel@tonic-gate 					exec = getexecuser(username, KV_COMMAND,
146*7c478bd9Sstevel@tonic-gate 					    NULL, GET_ALL);
147*7c478bd9Sstevel@tonic-gate 					print_profs_long(username,
148*7c478bd9Sstevel@tonic-gate 					    exec, print_flag);
149*7c478bd9Sstevel@tonic-gate 					free_execattr(exec);
150*7c478bd9Sstevel@tonic-gate 				} else {
151*7c478bd9Sstevel@tonic-gate 					print_profs(username, profArray,
152*7c478bd9Sstevel@tonic-gate 					    print_flag, profcnt);
153*7c478bd9Sstevel@tonic-gate 				}
154*7c478bd9Sstevel@tonic-gate 			}
155*7c478bd9Sstevel@tonic-gate 		}
156*7c478bd9Sstevel@tonic-gate 	}
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate 	if (status == EXIT_NON_FATAL) {
159*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "%s: %s : ", progname, username);
160*7c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, gettext("No profiles\n"));
161*7c478bd9Sstevel@tonic-gate 	}
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 	return (status);
164*7c478bd9Sstevel@tonic-gate }
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate static int
168*7c478bd9Sstevel@tonic-gate list_profs(userattr_t *user, int print_flag)
169*7c478bd9Sstevel@tonic-gate {
170*7c478bd9Sstevel@tonic-gate 	register int	status = EXIT_OK;
171*7c478bd9Sstevel@tonic-gate 	char		*proflist = (char *)NULL;
172*7c478bd9Sstevel@tonic-gate 	execattr_t	*exec = (execattr_t *)NULL;
173*7c478bd9Sstevel@tonic-gate 	char		*profArray[MAXPROFS];
174*7c478bd9Sstevel@tonic-gate 	int		profcnt = 0;
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate 	if (print_flag & PRINT_LONG) {
177*7c478bd9Sstevel@tonic-gate 		exec = getexecuser(user->name, KV_COMMAND, NULL, GET_ALL);
178*7c478bd9Sstevel@tonic-gate 		if (exec == NULL) {
179*7c478bd9Sstevel@tonic-gate 			status = EXIT_NON_FATAL;
180*7c478bd9Sstevel@tonic-gate 		}
181*7c478bd9Sstevel@tonic-gate 	} else {
182*7c478bd9Sstevel@tonic-gate 		proflist = kva_match(user->attr, USERATTR_PROFILES_KW);
183*7c478bd9Sstevel@tonic-gate 		if (proflist != NULL) {
184*7c478bd9Sstevel@tonic-gate 			getProfiles(proflist, profArray, &profcnt);
185*7c478bd9Sstevel@tonic-gate 		}
186*7c478bd9Sstevel@tonic-gate 		/* Also get any default profiles */
187*7c478bd9Sstevel@tonic-gate 		getDefaultProfiles(profArray, &profcnt);
188*7c478bd9Sstevel@tonic-gate 		if (profcnt == 0) {
189*7c478bd9Sstevel@tonic-gate 			status = EXIT_NON_FATAL;
190*7c478bd9Sstevel@tonic-gate 		}
191*7c478bd9Sstevel@tonic-gate 	}
192*7c478bd9Sstevel@tonic-gate 	if (status == EXIT_OK) {
193*7c478bd9Sstevel@tonic-gate 		if (print_flag & PRINT_LONG) {
194*7c478bd9Sstevel@tonic-gate 			print_profs_long(user->name, exec, print_flag);
195*7c478bd9Sstevel@tonic-gate 			free_execattr(exec);
196*7c478bd9Sstevel@tonic-gate 		} else {
197*7c478bd9Sstevel@tonic-gate 			print_profs(user->name, profArray,
198*7c478bd9Sstevel@tonic-gate 			    print_flag, profcnt);
199*7c478bd9Sstevel@tonic-gate 		}
200*7c478bd9Sstevel@tonic-gate 	}
201*7c478bd9Sstevel@tonic-gate 	free_userattr(user);
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate 	return (status);
204*7c478bd9Sstevel@tonic-gate }
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate static void
208*7c478bd9Sstevel@tonic-gate print_profs_long(char *user, void *data, int print_flag)
209*7c478bd9Sstevel@tonic-gate {
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate 	register int		i;
212*7c478bd9Sstevel@tonic-gate 	register int		len;
213*7c478bd9Sstevel@tonic-gate 	int			outlen;
214*7c478bd9Sstevel@tonic-gate 	char			tmpstr[TMP_BUF_LEN];
215*7c478bd9Sstevel@tonic-gate 	register char		*empty = "";
216*7c478bd9Sstevel@tonic-gate 	register char		*lastname = empty;
217*7c478bd9Sstevel@tonic-gate 	register char		*key;
218*7c478bd9Sstevel@tonic-gate 	register char		*val;
219*7c478bd9Sstevel@tonic-gate 	register kv_t		*kv_pair;
220*7c478bd9Sstevel@tonic-gate 	register execattr_t	*exec;
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate 	if (print_flag & PRINT_NAME) {
223*7c478bd9Sstevel@tonic-gate 		(void) printf("%s : ", user);
224*7c478bd9Sstevel@tonic-gate 	}
225*7c478bd9Sstevel@tonic-gate 	(void) printf("\n");
226*7c478bd9Sstevel@tonic-gate 	exec = (execattr_t *)data;
227*7c478bd9Sstevel@tonic-gate 	while (exec != (execattr_t *)NULL) {
228*7c478bd9Sstevel@tonic-gate 		if (strcmp(exec->name, lastname) != NULL) {
229*7c478bd9Sstevel@tonic-gate 			(void) snprintf(tmpstr, sizeof (tmpstr),
230*7c478bd9Sstevel@tonic-gate 			    "      %s:", exec->name);
231*7c478bd9Sstevel@tonic-gate 			(void) printf("%s\n", tmpstr);
232*7c478bd9Sstevel@tonic-gate 		}
233*7c478bd9Sstevel@tonic-gate 		(void) snprintf(tmpstr, sizeof (tmpstr),
234*7c478bd9Sstevel@tonic-gate 		    "          %s    ", exec->id);
235*7c478bd9Sstevel@tonic-gate 		outlen = strlen(tmpstr);
236*7c478bd9Sstevel@tonic-gate 		len = outlen;
237*7c478bd9Sstevel@tonic-gate 		(void) printf("%s", tmpstr);
238*7c478bd9Sstevel@tonic-gate 		if ((exec->attr == NULL) ||
239*7c478bd9Sstevel@tonic-gate 		    (kv_pair = exec->attr->data) == NULL) {
240*7c478bd9Sstevel@tonic-gate 			(void) printf("\n");
241*7c478bd9Sstevel@tonic-gate 			lastname = exec->name;
242*7c478bd9Sstevel@tonic-gate 			exec = exec->next;
243*7c478bd9Sstevel@tonic-gate 			continue;
244*7c478bd9Sstevel@tonic-gate 		}
245*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < exec->attr->length; i++) {
246*7c478bd9Sstevel@tonic-gate 			key = kv_pair[i].key;
247*7c478bd9Sstevel@tonic-gate 			val = kv_pair[i].value;
248*7c478bd9Sstevel@tonic-gate 			if ((key == NULL) || (val == NULL)) {
249*7c478bd9Sstevel@tonic-gate 				break;
250*7c478bd9Sstevel@tonic-gate 			}
251*7c478bd9Sstevel@tonic-gate 			if (i > 0) {
252*7c478bd9Sstevel@tonic-gate 				(void) strlcpy(tmpstr, ", ", TMP_BUF_LEN);
253*7c478bd9Sstevel@tonic-gate 				format_attr(&outlen, len, tmpstr);
254*7c478bd9Sstevel@tonic-gate 			}
255*7c478bd9Sstevel@tonic-gate 			(void) snprintf(tmpstr, sizeof (tmpstr), "%s=%s",
256*7c478bd9Sstevel@tonic-gate 			    key, val);
257*7c478bd9Sstevel@tonic-gate 			format_attr(&outlen, len, tmpstr);
258*7c478bd9Sstevel@tonic-gate 		}
259*7c478bd9Sstevel@tonic-gate 		(void) printf("\n");
260*7c478bd9Sstevel@tonic-gate 		lastname = exec->name;
261*7c478bd9Sstevel@tonic-gate 		exec = exec->next;
262*7c478bd9Sstevel@tonic-gate 	}
263*7c478bd9Sstevel@tonic-gate }
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate static void
267*7c478bd9Sstevel@tonic-gate format_attr(int *outlen, int len, char *str)
268*7c478bd9Sstevel@tonic-gate {
269*7c478bd9Sstevel@tonic-gate 	int newline = 0;
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 	if ((MAX_LINE_LEN - *outlen) < strlen(str)) {
272*7c478bd9Sstevel@tonic-gate 		newline = 1;
273*7c478bd9Sstevel@tonic-gate 	}
274*7c478bd9Sstevel@tonic-gate 	if (newline) {
275*7c478bd9Sstevel@tonic-gate 		(void) printf("\n");
276*7c478bd9Sstevel@tonic-gate 		len += strlen(str);
277*7c478bd9Sstevel@tonic-gate 		(void) printf("%*s", len, str);
278*7c478bd9Sstevel@tonic-gate 		*outlen = len;
279*7c478bd9Sstevel@tonic-gate 	} else {
280*7c478bd9Sstevel@tonic-gate 		*outlen += strlen(str);
281*7c478bd9Sstevel@tonic-gate 		(void) printf("%s", str);
282*7c478bd9Sstevel@tonic-gate 	}
283*7c478bd9Sstevel@tonic-gate }
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate static void
286*7c478bd9Sstevel@tonic-gate usage()
287*7c478bd9Sstevel@tonic-gate {
288*7c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr,
289*7c478bd9Sstevel@tonic-gate 	    gettext("  usage: profiles [-l] [user1 user2 ...]\n"));
290*7c478bd9Sstevel@tonic-gate }
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate static void
293*7c478bd9Sstevel@tonic-gate getProfiles(char *profiles, char **profArray, int *profcnt) {
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate 	char		*prof;
296*7c478bd9Sstevel@tonic-gate 	char		*lasts;
297*7c478bd9Sstevel@tonic-gate 
298*7c478bd9Sstevel@tonic-gate 	for (prof = (char *)strtok_r(profiles, PROFLIST_SEP, &lasts);
299*7c478bd9Sstevel@tonic-gate 	    prof != NULL;
300*7c478bd9Sstevel@tonic-gate 	    prof = (char *)strtok_r(NULL, PROFLIST_SEP, &lasts)) {
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate 		getproflist(prof, profArray, profcnt);
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate 	}
305*7c478bd9Sstevel@tonic-gate }
306*7c478bd9Sstevel@tonic-gate 
307*7c478bd9Sstevel@tonic-gate static void
308*7c478bd9Sstevel@tonic-gate print_profs(char *user, char **profnames, int print_flag, int profcnt)
309*7c478bd9Sstevel@tonic-gate {
310*7c478bd9Sstevel@tonic-gate 
311*7c478bd9Sstevel@tonic-gate 	int i;
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate 	if (print_flag & PRINT_NAME) {
314*7c478bd9Sstevel@tonic-gate 		(void) printf("%s : ", user);
315*7c478bd9Sstevel@tonic-gate 	}
316*7c478bd9Sstevel@tonic-gate 
317*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < profcnt; i++) {
318*7c478bd9Sstevel@tonic-gate 		(void) printf("%s\n", profnames[i]);
319*7c478bd9Sstevel@tonic-gate 	}
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate 	free_proflist(profnames, profcnt);
322*7c478bd9Sstevel@tonic-gate }
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate /*
325*7c478bd9Sstevel@tonic-gate  * Get the list of default profiles from /etc/security/policy.conf
326*7c478bd9Sstevel@tonic-gate  */
327*7c478bd9Sstevel@tonic-gate static void
328*7c478bd9Sstevel@tonic-gate getDefaultProfiles(char **profArray, int *profcnt)
329*7c478bd9Sstevel@tonic-gate {
330*7c478bd9Sstevel@tonic-gate 	char *profs = NULL;
331*7c478bd9Sstevel@tonic-gate 
332*7c478bd9Sstevel@tonic-gate 	if (defopen(AUTH_POLICY) == NULL) {
333*7c478bd9Sstevel@tonic-gate 		profs = defread(DEF_PROF);
334*7c478bd9Sstevel@tonic-gate 	}
335*7c478bd9Sstevel@tonic-gate 
336*7c478bd9Sstevel@tonic-gate 	if (profs != NULL) {
337*7c478bd9Sstevel@tonic-gate 		getProfiles(profs, profArray, profcnt);
338*7c478bd9Sstevel@tonic-gate 	}
339*7c478bd9Sstevel@tonic-gate 
340*7c478bd9Sstevel@tonic-gate }
341