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)
* ________________________________________________________________________ */
int adduser_main(int argc, char **argv)
{
- int i = 0;
- char opt;
+ int opt;
const char *login;
const char *gecos;
const char *home = NULL;
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 ();
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 $ */