xref: /titanic_52/usr/src/tools/protocmp/stdusers.c (revision e7cbe64f7a72dae5cb44f100db60ca88f3313c65)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <string.h>
29 #include "stdusers.h"
30 
31 /* LINTLIBRARY */
32 
33 const struct stdlist usernames[] = {
34 	{ "root", 0 },
35 	{ "daemon", 1 },
36 	{ "bin", 2 },
37 	{ "sys", 3 },
38 	{ "adm", 4 },
39 	{ "uucp", 5 },
40 	{ "nuucp", 9 },
41 	{ "dladm", 15 },
42 	{ "smmsp", 25 },
43 	{ "listen", 37 },
44 	{ "gdm", 50 },
45 	{ "lp", 71 },
46 	{ "mysql", 70 },
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 	{ "smmsp", 25 },
71 	{ "gdm", 50 },
72 	{ "mysql", 70 },
73 	{ "webservd", 80 },
74 	{ "postgres", 90 },
75 	{ "nobody", 60001 },
76 	{ "noaccess", 60002 },
77 	{ "nogroup", 65534 },
78 	{ NULL, 0 }
79 };
80 
81 int
82 stdfind(const char *name, const struct stdlist *list)
83 {
84 	while (list->name != NULL) {
85 		if (strcmp(name, list->name) == 0)
86 			return (list->value);
87 		list++;
88 	}
89 	return (-1);
90 }
91 
92 const char *
93 stdfindbyvalue(int value, const struct stdlist *list)
94 {
95 	while (list->name != NULL) {
96 		if (value == list->value)
97 			return (list->name);
98 		list++;
99 	}
100 	return (NULL);
101 }
102