xref: /illumos-gate/usr/src/tools/protocmp/stdusers.c (revision 1db1721aaa637f7c122058e7fe330468a966e760)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <string.h>
27 #include "stdusers.h"
28 
29 /* LINTLIBRARY */
30 
31 const struct stdlist usernames[] = {
32 	{ "root", 0 },
33 	{ "daemon", 1 },
34 	{ "bin", 2 },
35 	{ "sys", 3 },
36 	{ "adm", 4 },
37 	{ "uucp", 5 },
38 	{ "nuucp", 9 },
39 	{ "dladm", 15 },
40 	{ "netadm", 16 },
41 	{ "netcfg", 17 },
42 	{ "listen", 37 },
43 	{ "gdm", 50 },
44 	{ "lp", 71 },
45 	{ "mysql", 70 },
46 	{ "openldap", 75 },
47 	{ "webservd", 80 },
48 	{ "postgres", 90 },
49 	{ "nobody", 60001 },
50 	{ "noaccess", 60002 },
51 	{ "nobody4", 65534 },
52 	{ NULL, 0 }
53 };
54 
55 const struct stdlist groupnames[] = {
56 	{ "root", 0 },
57 	{ "other", 1 },
58 	{ "bin", 2 },
59 	{ "sys", 3 },
60 	{ "adm", 4 },
61 	{ "uucp", 5 },
62 	{ "mail", 6 },
63 	{ "tty", 7 },
64 	{ "lp", 8 },
65 	{ "nuucp", 9 },
66 	{ "staff", 10 },
67 	{ "daemon", 12 },
68 	{ "sysadmin", 14 },
69 	{ "games", 20 },
70 	{ "gdm", 50 },
71 	{ "netadm", 65 },
72 	{ "mysql", 70 },
73 	{ "openldap", 75 },
74 	{ "webservd", 80 },
75 	{ "postgres", 90 },
76 	{ "slocate", 95 },
77 	{ "nobody", 60001 },
78 	{ "noaccess", 60002 },
79 	{ "nogroup", 65534 },
80 	{ NULL, 0 }
81 };
82 
83 int
stdfind(const char * name,const struct stdlist * list)84 stdfind(const char *name, const struct stdlist *list)
85 {
86 	while (list->name != NULL) {
87 		if (strcmp(name, list->name) == 0)
88 			return (list->value);
89 		list++;
90 	}
91 	return (-1);
92 }
93 
94 const char *
stdfindbyvalue(int value,const struct stdlist * list)95 stdfindbyvalue(int value, const struct stdlist *list)
96 {
97 	while (list->name != NULL) {
98 		if (value == list->value)
99 			return (list->name);
100 		list++;
101 	}
102 	return (NULL);
103 }
104