summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenys Vlasenko2010-01-09 20:57:06 +0100
committerDenys Vlasenko2010-01-09 20:57:06 +0100
commit4653e442ba66bd4917a6069293d4daff9691c61f (patch)
tree3a5e179afc32ebb62a365bbcc9ee1827d6641df6 /loginutils
parent02dd96f688994b5ef4f79a7cdf940b844d6ac52b (diff)
downloadbusybox-4653e442ba66bd4917a6069293d4daff9691c61f.zip
busybox-4653e442ba66bd4917a6069293d4daff9691c61f.tar.gz
adduser: more fixes to "add user to specified group"
function old new delta update_passwd 1246 1295 +49 adduser_main 727 725 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/adduser.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index ff30a59..5f593ac 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -65,11 +65,12 @@ static void passwd_study(struct passwd *p)
}
}
-static void addgroup_wrapper(struct passwd *p)
+static void addgroup_wrapper(struct passwd *p, const char *group_name)
{
char *cmd;
- cmd = xasprintf("addgroup -g %u '%s'", (unsigned)p->pw_gid, p->pw_name);
+ cmd = xasprintf("addgroup '%s' '%s'",
+ p->pw_name, group_name);
system(cmd);
free(cmd);
}
@@ -191,7 +192,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
/* addgroup should be responsible for dealing w/ gshadow */
/* if using a pre-existing group, don't create one */
if (usegroup)
- addgroup_wrapper(&pw);
+ addgroup_wrapper(&pw, usegroup);
/* clear the umask for this process so it doesn't
* screw up the permissions on the mkdir and chown. */