diff options
Diffstat (limited to 'loginutils/adduser.c')
-rw-r--r-- | loginutils/adduser.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 913dbaf83..8b92df923 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -10,14 +10,10 @@ | |||
10 | //config:config ADDUSER | 10 | //config:config ADDUSER |
11 | //config: bool "adduser (15 kb)" | 11 | //config: bool "adduser (15 kb)" |
12 | //config: default y | 12 | //config: default y |
13 | //config: select LONG_OPTS | ||
13 | //config: help | 14 | //config: help |
14 | //config: Utility for creating a new user account. | 15 | //config: Utility for creating a new user account. |
15 | //config: | 16 | //config: |
16 | //config:config FEATURE_ADDUSER_LONG_OPTIONS | ||
17 | //config: bool "Enable long options" | ||
18 | //config: default y | ||
19 | //config: depends on ADDUSER && LONG_OPTS | ||
20 | //config: | ||
21 | //config:config FEATURE_CHECK_NAMES | 17 | //config:config FEATURE_CHECK_NAMES |
22 | //config: bool "Enable sanity check on user/group names in adduser and addgroup" | 18 | //config: bool "Enable sanity check on user/group names in adduser and addgroup" |
23 | //config: default n | 19 | //config: default n |
@@ -148,15 +144,7 @@ static int addgroup_wrapper(struct passwd *p, const char *group_name) | |||
148 | /* Add user to his own group with the first free gid | 144 | /* Add user to his own group with the first free gid |
149 | * found in passwd_study. | 145 | * found in passwd_study. |
150 | */ | 146 | */ |
151 | #if ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS || !ENABLE_ADDGROUP | ||
152 | /* We try to use --gid, not -g, because "standard" addgroup | ||
153 | * has no short option -g, it has only long --gid. | ||
154 | */ | ||
155 | argv[1] = (char*)"--gid"; | 147 | argv[1] = (char*)"--gid"; |
156 | #else | ||
157 | /* Breaks if system in fact does NOT use busybox addgroup */ | ||
158 | argv[1] = (char*)"-g"; | ||
159 | #endif | ||
160 | argv[2] = utoa(p->pw_gid); | 148 | argv[2] = utoa(p->pw_gid); |
161 | argv[3] = (char*)"--"; | 149 | argv[3] = (char*)"--"; |
162 | argv[4] = p->pw_name; | 150 | argv[4] = p->pw_name; |
@@ -174,7 +162,7 @@ static void passwd_wrapper(const char *login_name) | |||
174 | bb_error_msg_and_die("can't execute passwd, you must set password manually"); | 162 | bb_error_msg_and_die("can't execute passwd, you must set password manually"); |
175 | } | 163 | } |
176 | 164 | ||
177 | #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS | 165 | //FIXME: upstream adduser has no short options! NOT COMPATIBLE! |
178 | static const char adduser_longopts[] ALIGN1 = | 166 | static const char adduser_longopts[] ALIGN1 = |
179 | "home\0" Required_argument "h" | 167 | "home\0" Required_argument "h" |
180 | "gecos\0" Required_argument "g" | 168 | "gecos\0" Required_argument "g" |
@@ -187,7 +175,6 @@ static const char adduser_longopts[] ALIGN1 = | |||
187 | "uid\0" Required_argument "u" | 175 | "uid\0" Required_argument "u" |
188 | "skel\0" Required_argument "k" | 176 | "skel\0" Required_argument "k" |
189 | ; | 177 | ; |
190 | #endif | ||
191 | 178 | ||
192 | /* | 179 | /* |
193 | * adduser will take a login_name as its first parameter. | 180 | * adduser will take a login_name as its first parameter. |
@@ -204,10 +191,6 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
204 | char *uid; | 191 | char *uid; |
205 | const char *skel = "/etc/skel"; | 192 | const char *skel = "/etc/skel"; |
206 | 193 | ||
207 | #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS | ||
208 | applet_long_options = adduser_longopts; | ||
209 | #endif | ||
210 | |||
211 | /* got root? */ | 194 | /* got root? */ |
212 | if (geteuid()) { | 195 | if (geteuid()) { |
213 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); | 196 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
@@ -221,7 +204,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
221 | /* at least one and at most two non-option args */ | 204 | /* at least one and at most two non-option args */ |
222 | /* disable interactive passwd for system accounts */ | 205 | /* disable interactive passwd for system accounts */ |
223 | opt_complementary = "-1:?2:SD"; | 206 | opt_complementary = "-1:?2:SD"; |
224 | opts = getopt32(argv, "h:g:s:G:DSHu:k:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid, &skel); | 207 | opts = getopt32long(argv, "h:g:s:G:DSHu:k:", adduser_longopts, |
208 | &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, | ||
209 | &usegroup, &uid, &skel); | ||
225 | if (opts & OPT_UID) | 210 | if (opts & OPT_UID) |
226 | pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID); | 211 | pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID); |
227 | 212 | ||