diff options
author | Eric Andersen | 2002-11-14 11:10:14 +0000 |
---|---|---|
committer | Eric Andersen | 2002-11-14 11:10:14 +0000 |
commit | 09eb000d7a21854e395c547420e02bd21e887042 (patch) | |
tree | c7a00320e68abdd42dea5482a12294bf15113320 /loginutils | |
parent | f870148a04dae35458c29f78ff082bf573ee8bcb (diff) | |
download | busybox-09eb000d7a21854e395c547420e02bd21e887042.zip busybox-09eb000d7a21854e395c547420e02bd21e887042.tar.gz |
Patch from Marcel Hamer to fix addgroup argument parsing
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/addgroup.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index 7878a38..f4c0245 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -132,27 +132,20 @@ static int addgroup(const char *filename, char *group, gid_t gid) * ________________________________________________________________________ */ int addgroup_main(int argc, char **argv) { - int opt; char *group; gid_t gid = 0; - /* get remaining args */ - while ((opt = getopt (argc, argv, "g:")) != -1) - switch (opt) { - case 'g': - gid = strtol(optarg, NULL, 10); - break; - default: - show_usage(); - break; - } - - if (optind >= argc) { + if (argc < 2) { show_usage(); - } else { - group = argv[optind]; } + if (strncmp(argv[1], "-g", 2) == 0) { + gid = strtol(argv[2], NULL, 10); + group = argv[2]; + } else { + show_usage(); + } + if (geteuid() != 0) { error_msg_and_die ("Only root may add a group to the system."); @@ -162,4 +155,4 @@ int addgroup_main(int argc, char **argv) return addgroup(group_file, group, gid); } -/* $Id: addgroup.c,v 1.5 2002/08/06 20:39:23 mjn3 Exp $ */ +/* $Id: addgroup.c,v 1.6 2002/11/14 11:10:14 andersen Exp $ */ |