From 4653e442ba66bd4917a6069293d4daff9691c61f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 9 Jan 2010 20:57:06 +0100 Subject: 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 --- loginutils/adduser.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'loginutils') diff --git a/loginutils/adduser.c b/loginutils/adduser.c index ff30a592d..5f593ac16 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. */ -- cgit v1.2.3