aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--loginutils/addgroup.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 7878a387b..f4c024516 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -132,27 +132,20 @@ static int addgroup(const char *filename, char *group, gid_t gid)
132 * ________________________________________________________________________ */ 132 * ________________________________________________________________________ */
133int addgroup_main(int argc, char **argv) 133int addgroup_main(int argc, char **argv)
134{ 134{
135 int opt;
136 char *group; 135 char *group;
137 gid_t gid = 0; 136 gid_t gid = 0;
138 137
139 /* get remaining args */ 138 if (argc < 2) {
140 while ((opt = getopt (argc, argv, "g:")) != -1)
141 switch (opt) {
142 case 'g':
143 gid = strtol(optarg, NULL, 10);
144 break;
145 default:
146 show_usage();
147 break;
148 }
149
150 if (optind >= argc) {
151 show_usage(); 139 show_usage();
152 } else {
153 group = argv[optind];
154 } 140 }
155 141
142 if (strncmp(argv[1], "-g", 2) == 0) {
143 gid = strtol(argv[2], NULL, 10);
144 group = argv[2];
145 } else {
146 show_usage();
147 }
148
156 if (geteuid() != 0) { 149 if (geteuid() != 0) {
157 error_msg_and_die 150 error_msg_and_die
158 ("Only root may add a group to the system."); 151 ("Only root may add a group to the system.");
@@ -162,4 +155,4 @@ int addgroup_main(int argc, char **argv)
162 return addgroup(group_file, group, gid); 155 return addgroup(group_file, group, gid);
163} 156}
164 157
165/* $Id: addgroup.c,v 1.5 2002/08/06 20:39:23 mjn3 Exp $ */ 158/* $Id: addgroup.c,v 1.6 2002/11/14 11:10:14 andersen Exp $ */