diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-09 20:57:06 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-09 20:57:06 +0100 |
commit | 4653e442ba66bd4917a6069293d4daff9691c61f (patch) | |
tree | 3a5e179afc32ebb62a365bbcc9ee1827d6641df6 /loginutils/adduser.c | |
parent | 02dd96f688994b5ef4f79a7cdf940b844d6ac52b (diff) | |
download | busybox-w32-4653e442ba66bd4917a6069293d4daff9691c61f.tar.gz busybox-w32-4653e442ba66bd4917a6069293d4daff9691c61f.tar.bz2 busybox-w32-4653e442ba66bd4917a6069293d4daff9691c61f.zip |
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/adduser.c')
-rw-r--r-- | loginutils/adduser.c | 7 |
1 files changed, 4 insertions, 3 deletions
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) | |||
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | static void addgroup_wrapper(struct passwd *p) | 68 | static void addgroup_wrapper(struct passwd *p, const char *group_name) |
69 | { | 69 | { |
70 | char *cmd; | 70 | char *cmd; |
71 | 71 | ||
72 | cmd = xasprintf("addgroup -g %u '%s'", (unsigned)p->pw_gid, p->pw_name); | 72 | cmd = xasprintf("addgroup '%s' '%s'", |
73 | p->pw_name, group_name); | ||
73 | system(cmd); | 74 | system(cmd); |
74 | free(cmd); | 75 | free(cmd); |
75 | } | 76 | } |
@@ -191,7 +192,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
191 | /* addgroup should be responsible for dealing w/ gshadow */ | 192 | /* addgroup should be responsible for dealing w/ gshadow */ |
192 | /* if using a pre-existing group, don't create one */ | 193 | /* if using a pre-existing group, don't create one */ |
193 | if (usegroup) | 194 | if (usegroup) |
194 | addgroup_wrapper(&pw); | 195 | addgroup_wrapper(&pw, usegroup); |
195 | 196 | ||
196 | /* clear the umask for this process so it doesn't | 197 | /* clear the umask for this process so it doesn't |
197 | * screw up the permissions on the mkdir and chown. */ | 198 | * screw up the permissions on the mkdir and chown. */ |