diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-21 19:57:58 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-21 19:57:58 +0200 |
commit | 569e930768922812ce5169a3058b65fff9196308 (patch) | |
tree | 4b957c01e4446e92017fc1f4c9f6d20dab6394d7 | |
parent | b808614785d04753b689233d27614189e25f6f0c (diff) | |
download | busybox-w32-569e930768922812ce5169a3058b65fff9196308.tar.gz busybox-w32-569e930768922812ce5169a3058b65fff9196308.tar.bz2 busybox-w32-569e930768922812ce5169a3058b65fff9196308.zip |
adduser: prefer to call addgroup --gid, not non-std addgroup -g
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | loginutils/adduser.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index a05b72158..0e06ab2f5 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -67,6 +67,7 @@ static void passwd_study(struct passwd *p) | |||
67 | } | 67 | } |
68 | if (p->pw_uid == max) { | 68 | if (p->pw_uid == max) { |
69 | bb_error_msg_and_die("no %cids left", 'u'); | 69 | bb_error_msg_and_die("no %cids left", 'u'); |
70 | /* this format string is reused in adduser and addgroup */ | ||
70 | } | 71 | } |
71 | p->pw_uid++; | 72 | p->pw_uid++; |
72 | } | 73 | } |
@@ -92,9 +93,16 @@ static void addgroup_wrapper(struct passwd *p, const char *group_name) | |||
92 | argv[3] = (char*)group_name; | 93 | argv[3] = (char*)group_name; |
93 | argv[4] = NULL; | 94 | argv[4] = NULL; |
94 | } else { | 95 | } else { |
95 | /* Add user to his own group with the first free gid found in passwd_study */ | 96 | /* Add user to his own group with the first free gid |
96 | //TODO: to be compatible with external addgroup programs we should use --gid instead... | 97 | * found in passwd_study. |
98 | * We try to use --gid, not -g, because "standard" addgroup | ||
99 | * has no such short option, it has only long --gid. | ||
100 | */ | ||
101 | #if ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS | ||
102 | argv[1] = (char*)"--gid"; | ||
103 | #else | ||
97 | argv[1] = (char*)"-g"; | 104 | argv[1] = (char*)"-g"; |
105 | #endif | ||
98 | argv[2] = utoa(p->pw_gid); | 106 | argv[2] = utoa(p->pw_gid); |
99 | argv[3] = (char*)"--"; | 107 | argv[3] = (char*)"--"; |
100 | argv[4] = p->pw_name; | 108 | argv[4] = p->pw_name; |
@@ -230,9 +238,11 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
230 | if (mkdir_err == 0) { | 238 | if (mkdir_err == 0) { |
231 | /* New home. Copy /etc/skel to it */ | 239 | /* New home. Copy /etc/skel to it */ |
232 | const char *args[] = { | 240 | const char *args[] = { |
233 | "chown", "-R", | 241 | "chown", |
242 | "-R", | ||
234 | xasprintf("%u:%u", (int)pw.pw_uid, (int)pw.pw_gid), | 243 | xasprintf("%u:%u", (int)pw.pw_uid, (int)pw.pw_gid), |
235 | pw.pw_dir, NULL | 244 | pw.pw_dir, |
245 | NULL | ||
236 | }; | 246 | }; |
237 | /* Be silent on any errors (like: no /etc/skel) */ | 247 | /* Be silent on any errors (like: no /etc/skel) */ |
238 | logmode = LOGMODE_NONE; | 248 | logmode = LOGMODE_NONE; |