diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-16 23:49:13 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-16 23:49:13 +0000 |
commit | 9f739445cd3deddd0343c3a8d5a981ede26bef30 (patch) | |
tree | 6dc013e44d2281eb1e6f61c4bca1ae7546001f79 /loginutils/su.c | |
parent | a597aaddfa76d589d3e1a37b1f1c3401c2decffd (diff) | |
download | busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.tar.gz busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.tar.bz2 busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.zip |
inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid]
Diffstat (limited to 'loginutils/su.c')
-rw-r--r-- | loginutils/su.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/loginutils/su.c b/loginutils/su.c index a23ee932b..046457b6f 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -14,25 +14,29 @@ int su_main(int argc, char **argv) | |||
14 | char *opt_shell = 0; | 14 | char *opt_shell = 0; |
15 | char *opt_command = 0; | 15 | char *opt_command = 0; |
16 | char *opt_username = "root"; | 16 | char *opt_username = "root"; |
17 | char **opt_args = 0; | ||
18 | struct passwd *pw; | 17 | struct passwd *pw; |
19 | uid_t cur_uid = getuid(); | 18 | uid_t cur_uid = getuid(); |
20 | const char *tty; | 19 | const char *tty; |
21 | char *old_user; | 20 | char *old_user; |
22 | 21 | ||
23 | flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell); | 22 | flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell); |
23 | argc -= optind; | ||
24 | argv -= optind; | ||
24 | #define SU_OPT_mp (3) | 25 | #define SU_OPT_mp (3) |
25 | #define SU_OPT_l (4) | 26 | #define SU_OPT_l (4) |
26 | 27 | ||
27 | if (optind < argc && argv[optind][0] == '-' && argv[optind][1] == 0) { | 28 | if (argc && LONE_DASH(argv[0])) { |
28 | flags |= SU_OPT_l; | 29 | flags |= SU_OPT_l; |
29 | ++optind; | 30 | argc--; |
31 | argv++; | ||
30 | } | 32 | } |
31 | 33 | ||
32 | /* get user if specified */ | 34 | /* get user if specified */ |
33 | if (optind < argc) opt_username = argv [optind++]; | 35 | if (argc) { |
34 | 36 | opt_username = argv[0]; | |
35 | if (optind < argc) opt_args = argv + optind; | 37 | // argc--; |
38 | argv++; | ||
39 | } | ||
36 | 40 | ||
37 | if (ENABLE_SU_SYSLOG) { | 41 | if (ENABLE_SU_SYSLOG) { |
38 | /* The utmp entry (via getlogin) is probably the best way to identify | 42 | /* The utmp entry (via getlogin) is probably the best way to identify |
@@ -84,7 +88,7 @@ int su_main(int argc, char **argv) | |||
84 | USE_SELINUX(set_current_security_context(NULL);) | 88 | USE_SELINUX(set_current_security_context(NULL);) |
85 | 89 | ||
86 | /* Never returns */ | 90 | /* Never returns */ |
87 | run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)opt_args); | 91 | run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)argv); |
88 | 92 | ||
89 | return EXIT_FAILURE; | 93 | return EXIT_FAILURE; |
90 | } | 94 | } |