From: Robert Griebl Date: Tue, 16 Jul 2002 23:50:05 +0000 (-0000) Subject: Fix for the totally broken adduser applet (parts/ideas from vodz and tito) X-Git-Tag: 0_60_4~120 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2c0d0f00513e44f8545eb0756f874a25f54f9b40;p=oweals%2Fbusybox.git Fix for the totally broken adduser applet (parts/ideas from vodz and tito) --- diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 7aa7fcfd3..7455f23a6 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -110,18 +110,11 @@ static int passwd_study(const char *filename, struct passwd *p) static void addgroup_wrapper(const char *login, gid_t gid) { - int argc = 3; - const char *argv0_save; - char group_id[8]; - char group_name[32]; - char *argv[] = { group_name, "-g", group_id }; - - argv0_save = applet_name; - applet_name = "addgroup"; - safe_strncpy(group_name, login, 32); - sprintf(group_id, "%d", gid); - addgroup_main(argc, argv); - applet_name = argv0_save; + char *cmd = xmalloc(strlen(login)+32); + + sprintf(cmd, "addgroup -g %d %s", gid, login); + system(cmd); + free(cmd); } static void passwd_wrapper(const char *login) @@ -235,8 +228,7 @@ static inline uid_t i_am_not_root(void) * ________________________________________________________________________ */ int adduser_main(int argc, char **argv) { - int i = 0; - char opt; + int opt; const char *login; const char *gecos; const char *home = NULL; @@ -255,13 +247,13 @@ int adduser_main(int argc, char **argv) while ((opt = getopt (argc, argv, "h:g:s:")) != -1) switch (opt) { case 'h': - home = argv[++i]; + home = optarg; break; case 'g': - gecos = argv[++i]; + gecos = optarg; break; case 's': - shell = argv[++i]; + shell = optarg; break; default: show_usage (); @@ -301,4 +293,4 @@ int adduser_main(int argc, char **argv) return adduser(passwd_file, &pw); } -/* $Id: adduser.c,v 1.2 2002/06/23 04:24:24 andersen Exp $ */ +/* $Id: adduser.c,v 1.3 2002/07/16 23:50:05 sandman Exp $ */