Fix for the totally broken adduser applet (parts/ideas from vodz and tito)
This commit is contained in:
parent
e4f9f3a960
commit
2c0d0f0051
@ -110,18 +110,11 @@ static int passwd_study(const char *filename, struct passwd *p)
|
|||||||
|
|
||||||
static void addgroup_wrapper(const char *login, gid_t gid)
|
static void addgroup_wrapper(const char *login, gid_t gid)
|
||||||
{
|
{
|
||||||
int argc = 3;
|
char *cmd = xmalloc(strlen(login)+32);
|
||||||
const char *argv0_save;
|
|
||||||
char group_id[8];
|
|
||||||
char group_name[32];
|
|
||||||
char *argv[] = { group_name, "-g", group_id };
|
|
||||||
|
|
||||||
argv0_save = applet_name;
|
sprintf(cmd, "addgroup -g %d %s", gid, login);
|
||||||
applet_name = "addgroup";
|
system(cmd);
|
||||||
safe_strncpy(group_name, login, 32);
|
free(cmd);
|
||||||
sprintf(group_id, "%d", gid);
|
|
||||||
addgroup_main(argc, argv);
|
|
||||||
applet_name = argv0_save;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void passwd_wrapper(const char *login)
|
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 adduser_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int opt;
|
||||||
char opt;
|
|
||||||
const char *login;
|
const char *login;
|
||||||
const char *gecos;
|
const char *gecos;
|
||||||
const char *home = NULL;
|
const char *home = NULL;
|
||||||
@ -255,13 +247,13 @@ int adduser_main(int argc, char **argv)
|
|||||||
while ((opt = getopt (argc, argv, "h:g:s:")) != -1)
|
while ((opt = getopt (argc, argv, "h:g:s:")) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
home = argv[++i];
|
home = optarg;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
gecos = argv[++i];
|
gecos = optarg;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
shell = argv[++i];
|
shell = optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
show_usage ();
|
show_usage ();
|
||||||
@ -301,4 +293,4 @@ int adduser_main(int argc, char **argv)
|
|||||||
return adduser(passwd_file, &pw);
|
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 $ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user