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