xref: /onnv-gate/usr/src/tools/protocmp/stdusers.c (revision 7647:e6aecdc65c47)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52977Smeem  * Common Development and Distribution License (the "License").
62977Smeem  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
225983Ssm156471  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <string.h>
270Sstevel@tonic-gate #include "stdusers.h"
280Sstevel@tonic-gate 
291384Smike_s /* LINTLIBRARY */
301384Smike_s 
310Sstevel@tonic-gate const struct stdlist usernames[] = {
320Sstevel@tonic-gate 	{ "root", 0 },
330Sstevel@tonic-gate 	{ "daemon", 1 },
340Sstevel@tonic-gate 	{ "bin", 2 },
350Sstevel@tonic-gate 	{ "sys", 3 },
360Sstevel@tonic-gate 	{ "adm", 4 },
370Sstevel@tonic-gate 	{ "uucp", 5 },
380Sstevel@tonic-gate 	{ "nuucp", 9 },
392977Smeem 	{ "dladm", 15 },
400Sstevel@tonic-gate 	{ "smmsp", 25 },
410Sstevel@tonic-gate 	{ "listen", 37 },
421384Smike_s 	{ "gdm", 50 },
430Sstevel@tonic-gate 	{ "lp", 71 },
445983Ssm156471 	{ "mysql", 70 },
451384Smike_s 	{ "webservd", 80 },
463342Sjg97986 	{ "postgres", 90 },
470Sstevel@tonic-gate 	{ "nobody", 60001 },
480Sstevel@tonic-gate 	{ "noaccess", 60002 },
490Sstevel@tonic-gate 	{ "nobody4", 65534 },
500Sstevel@tonic-gate 	{ NULL, 0 }
510Sstevel@tonic-gate };
520Sstevel@tonic-gate 
530Sstevel@tonic-gate const struct stdlist groupnames[] = {
540Sstevel@tonic-gate 	{ "root", 0 },
550Sstevel@tonic-gate 	{ "other", 1 },
560Sstevel@tonic-gate 	{ "bin", 2 },
570Sstevel@tonic-gate 	{ "sys", 3 },
580Sstevel@tonic-gate 	{ "adm", 4 },
590Sstevel@tonic-gate 	{ "uucp", 5 },
600Sstevel@tonic-gate 	{ "mail", 6 },
610Sstevel@tonic-gate 	{ "tty", 7 },
620Sstevel@tonic-gate 	{ "lp", 8 },
630Sstevel@tonic-gate 	{ "nuucp", 9 },
640Sstevel@tonic-gate 	{ "staff", 10 },
650Sstevel@tonic-gate 	{ "daemon", 12 },
660Sstevel@tonic-gate 	{ "sysadmin", 14 },
676315Sdduvall 	{ "games", 20 },
680Sstevel@tonic-gate 	{ "smmsp", 25 },
691384Smike_s 	{ "gdm", 50 },
705983Ssm156471 	{ "mysql", 70 },
711384Smike_s 	{ "webservd", 80 },
723342Sjg97986 	{ "postgres", 90 },
73*7647SJim.Li@Sun.COM 	{ "slocate", 95 },
740Sstevel@tonic-gate 	{ "nobody", 60001 },
750Sstevel@tonic-gate 	{ "noaccess", 60002 },
760Sstevel@tonic-gate 	{ "nogroup", 65534 },
770Sstevel@tonic-gate 	{ NULL, 0 }
780Sstevel@tonic-gate };
790Sstevel@tonic-gate 
800Sstevel@tonic-gate int
810Sstevel@tonic-gate stdfind(const char *name, const struct stdlist *list)
820Sstevel@tonic-gate {
830Sstevel@tonic-gate 	while (list->name != NULL) {
840Sstevel@tonic-gate 		if (strcmp(name, list->name) == 0)
850Sstevel@tonic-gate 			return (list->value);
860Sstevel@tonic-gate 		list++;
870Sstevel@tonic-gate 	}
880Sstevel@tonic-gate 	return (-1);
890Sstevel@tonic-gate }
901384Smike_s 
911384Smike_s const char *
921384Smike_s stdfindbyvalue(int value, const struct stdlist *list)
931384Smike_s {
941384Smike_s 	while (list->name != NULL) {
951384Smike_s 		if (value == list->value)
961384Smike_s 			return (list->name);
971384Smike_s 		list++;
981384Smike_s 	}
991384Smike_s 	return (NULL);
1001384Smike_s }
101