Print this page
4078 groupadd execs getent unnecessarily
Reviewed by: Rich Lowe <richlowe@richlowe.net>
Reviewed by: Gary Mills <gary_mills@fastmail.fm>
Reviewed by: Milan Jurik <milan.jurik@xylab.cz>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/oamuser/user/val_lprj.c
+++ new/usr/src/cmd/oamuser/user/val_lprj.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 -#pragma ident "%Z%%M% %I% %E% SMI"
27 +/*
28 + * Copyright (c) 2013 RackTop Systems.
29 + */
28 30
29 31 #include <sys/types.h>
30 32 #include <stdio.h>
31 33 #include <strings.h>
32 34 #include <sys/param.h>
33 35 #include <users.h>
34 36 #include <userdefs.h>
35 37 #include <project.h>
36 38 #include <errno.h>
37 39 #include "messages.h"
38 40
39 41
40 42 static projid_t projlist[NPROJECTS_MAX + 1];
41 43 static int nproj_max = NPROJECTS_MAX;
42 44
43 45 /* Validate a list of projects */
44 46 int **
45 47 valid_lproject(char *list)
46 48 {
47 49 int n_invalid = 0;
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
48 50 int i = 0;
49 51 int j;
50 52 char *ptr;
51 53 struct project projent;
52 54 int warning;
53 55 char mybuf[PROJECT_BUFSZ];
54 56
55 57 if (!list || !*list)
56 58 return ((int **)NULL);
57 59
58 - while (ptr = strtok(((i || n_invalid) ? NULL : list), ",")) {
60 + while ((ptr = strtok((i || n_invalid) ? NULL : list, ","))) {
59 61
60 62 switch (valid_project(ptr, &projent, mybuf, sizeof (mybuf),
61 63 &warning)) {
62 64 case INVALID:
63 65 errmsg(M_INVALID, ptr, "project id");
64 66 n_invalid++;
65 67 break;
66 68 case TOOBIG:
67 69 errmsg(M_TOOBIG, "projid", ptr);
68 70 n_invalid++;
69 71 break;
70 72 case UNIQUE:
71 73 errmsg(M_PROJ_NOTUSED, ptr);
72 74 n_invalid++;
73 75 break;
74 76 case NOTUNIQUE:
75 77 if (!i)
76 78 /* ignore respecified primary */
77 79 projlist[i++] = projent.pj_projid;
78 80 else {
79 81 /* Keep out duplicates */
80 82 for (j = 0; j < i; j++)
81 83 if (projent.pj_projid == projlist[j])
82 84 break;
83 85
84 86 if (j == i)
85 87 /* Not a duplicate */
86 88 projlist[i++] = projent.pj_projid;
87 89 }
88 90 break;
89 91 }
90 92 if (warning)
91 93 warningmsg(warning, ptr);
92 94
93 95 if (i >= nproj_max) {
94 96 errmsg(M_MAXPROJECTS, nproj_max);
95 97 break;
96 98 }
97 99 }
98 100
99 101 /* Terminate the list */
100 102 projlist[i] = -1;
101 103
102 104 if (n_invalid)
103 105 exit(EX_BADARG);
104 106
105 107 return ((int **)projlist);
106 108 }
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX