xref: /illumos-gate/usr/src/tools/protocmp/stdusers.c (revision 46b592853d0f4f11781b6b0a7533f267c6aee132)
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 2008 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 	{ "smmsp", 25 },
41 	{ "listen", 37 },
42 	{ "gdm", 50 },
43 	{ "lp", 71 },
44 	{ "mysql", 70 },
45 	{ "openldap", 75 },
46 	{ "webservd", 80 },
47 	{ "postgres", 90 },
48 	{ "nobody", 60001 },
49 	{ "noaccess", 60002 },
50 	{ "nobody4", 65534 },
51 	{ NULL, 0 }
52 };
53 
54 const struct stdlist groupnames[] = {
55 	{ "root", 0 },
56 	{ "other", 1 },
57 	{ "bin", 2 },
58 	{ "sys", 3 },
59 	{ "adm", 4 },
60 	{ "uucp", 5 },
61 	{ "mail", 6 },
62 	{ "tty", 7 },
63 	{ "lp", 8 },
64 	{ "nuucp", 9 },
65 	{ "staff", 10 },
66 	{ "daemon", 12 },
67 	{ "sysadmin", 14 },
68 	{ "games", 20 },
69 	{ "smmsp", 25 },
70 	{ "gdm", 50 },
71 	{ "mysql", 70 },
72 	{ "openldap", 75 },
73 	{ "webservd", 80 },
74 	{ "postgres", 90 },
75 	{ "slocate", 95 },
76 	{ "nobody", 60001 },
77 	{ "noaccess", 60002 },
78 	{ "nogroup", 65534 },
79 	{ NULL, 0 }
80 };
81 
82 int
83 stdfind(const char *name, const struct stdlist *list)
84 {
85 	while (list->name != NULL) {
86 		if (strcmp(name, list->name) == 0)
87 			return (list->value);
88 		list++;
89 	}
90 	return (-1);
91 }
92 
93 const char *
94 stdfindbyvalue(int value, const struct stdlist *list)
95 {
96 	while (list->name != NULL) {
97 		if (value == list->value)
98 			return (list->name);
99 		list++;
100 	}
101 	return (NULL);
102 }
103