diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-08 21:00:36 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-08 21:00:36 +0100 |
commit | 681efe20d327e9e6774b174a617d66bbb9d21f48 (patch) | |
tree | 4331e443ee303c24364b1655651c8584db8b51c1 | |
parent | 86cf0364bd58e07646a23a1128e4a9ea79189579 (diff) | |
download | busybox-w32-681efe20d327e9e6774b174a617d66bbb9d21f48.tar.gz busybox-w32-681efe20d327e9e6774b174a617d66bbb9d21f48.tar.bz2 busybox-w32-681efe20d327e9e6774b174a617d66bbb9d21f48.zip |
use user's shell instead of hardwired "/bin/sh" (android needs this)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/libarchive/data_extract_to_command.c | 8 | ||||
-rw-r--r-- | archival/tar.c | 1 | ||||
-rw-r--r-- | console-tools/openvt.c | 4 | ||||
-rw-r--r-- | coreutils/chroot.c | 8 | ||||
-rw-r--r-- | include/archive.h | 1 | ||||
-rw-r--r-- | include/libbb.h | 9 | ||||
-rw-r--r-- | loginutils/adduser.c | 3 | ||||
-rw-r--r-- | miscutils/conspy.c | 4 | ||||
-rw-r--r-- | miscutils/crontab.c | 7 | ||||
-rw-r--r-- | networking/ifupdown.c | 9 | ||||
-rw-r--r-- | runit/svlogd.c | 7 | ||||
-rw-r--r-- | util-linux/script.c | 5 |
12 files changed, 38 insertions, 28 deletions
diff --git a/archival/libarchive/data_extract_to_command.c b/archival/libarchive/data_extract_to_command.c index 2bbab7641..0e977049d 100644 --- a/archival/libarchive/data_extract_to_command.c +++ b/archival/libarchive/data_extract_to_command.c | |||
@@ -99,8 +99,12 @@ void FAST_FUNC data_extract_to_command(archive_handle_t *archive_handle) | |||
99 | close(p[1]); | 99 | close(p[1]); |
100 | xdup2(p[0], STDIN_FILENO); | 100 | xdup2(p[0], STDIN_FILENO); |
101 | signal(SIGPIPE, SIG_DFL); | 101 | signal(SIGPIPE, SIG_DFL); |
102 | execl(DEFAULT_SHELL, DEFAULT_SHELL_SHORT_NAME, "-c", archive_handle->tar__to_command, NULL); | 102 | execl(archive_handle->tar__to_command_shell, |
103 | bb_perror_msg_and_die("can't execute '%s'", DEFAULT_SHELL); | 103 | archive_handle->tar__to_command_shell, |
104 | "-c", | ||
105 | archive_handle->tar__to_command, | ||
106 | NULL); | ||
107 | bb_perror_msg_and_die("can't execute '%s'", archive_handle->tar__to_command_shell); | ||
104 | } | 108 | } |
105 | close(p[0]); | 109 | close(p[0]); |
106 | /* Our caller is expected to do signal(SIGPIPE, SIG_IGN) | 110 | /* Our caller is expected to do signal(SIGPIPE, SIG_IGN) |
diff --git a/archival/tar.c b/archival/tar.c index d43c8dee3..01b83d5e2 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -970,6 +970,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
970 | putenv((char*)"TAR_FILETYPE=f"); | 970 | putenv((char*)"TAR_FILETYPE=f"); |
971 | signal(SIGPIPE, SIG_IGN); | 971 | signal(SIGPIPE, SIG_IGN); |
972 | tar_handle->action_data = data_extract_to_command; | 972 | tar_handle->action_data = data_extract_to_command; |
973 | IF_FEATURE_TAR_TO_COMMAND(tar_handle->tar__to_command_shell = xstrdup(get_shell_name());) | ||
973 | } | 974 | } |
974 | 975 | ||
975 | if (opt & OPT_KEEP_OLD) | 976 | if (opt & OPT_KEEP_OLD) |
diff --git a/console-tools/openvt.c b/console-tools/openvt.c index 6e0b589a0..56f50c6cd 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c | |||
@@ -144,9 +144,7 @@ int openvt_main(int argc UNUSED_PARAM, char **argv) | |||
144 | 144 | ||
145 | if (!argv[0]) { | 145 | if (!argv[0]) { |
146 | argv--; | 146 | argv--; |
147 | argv[0] = getenv("SHELL"); | 147 | argv[0] = (char *) get_shell_name(); |
148 | if (!argv[0]) | ||
149 | argv[0] = (char *) DEFAULT_SHELL; | ||
150 | /*argv[1] = NULL; - already is */ | 148 | /*argv[1] = NULL; - already is */ |
151 | } | 149 | } |
152 | 150 | ||
diff --git a/coreutils/chroot.c b/coreutils/chroot.c index b80a12ee0..5ac2e890e 100644 --- a/coreutils/chroot.c +++ b/coreutils/chroot.c | |||
@@ -23,11 +23,9 @@ int chroot_main(int argc UNUSED_PARAM, char **argv) | |||
23 | ++argv; | 23 | ++argv; |
24 | if (!*argv) { /* no 2nd param (PROG), use shell */ | 24 | if (!*argv) { /* no 2nd param (PROG), use shell */ |
25 | argv -= 2; | 25 | argv -= 2; |
26 | argv[0] = getenv("SHELL"); | 26 | argv[0] = (char *) get_shell_name(); |
27 | if (!argv[0]) { | 27 | argv[1] = (char *) "-i"; /* GNU coreutils 8.4 compat */ |
28 | argv[0] = (char *) DEFAULT_SHELL; | 28 | /*argv[2] = NULL; - already is */ |
29 | } | ||
30 | argv[1] = (char *) "-i"; | ||
31 | } | 29 | } |
32 | 30 | ||
33 | BB_EXECVP_or_die(argv); | 31 | BB_EXECVP_or_die(argv); |
diff --git a/include/archive.h b/include/archive.h index 181c187f7..b139dc5be 100644 --- a/include/archive.h +++ b/include/archive.h | |||
@@ -84,6 +84,7 @@ typedef struct archive_handle_t { | |||
84 | # endif | 84 | # endif |
85 | #if ENABLE_FEATURE_TAR_TO_COMMAND | 85 | #if ENABLE_FEATURE_TAR_TO_COMMAND |
86 | char* tar__to_command; | 86 | char* tar__to_command; |
87 | const char* tar__to_command_shell; | ||
87 | #endif | 88 | #endif |
88 | # if ENABLE_FEATURE_TAR_SELINUX | 89 | # if ENABLE_FEATURE_TAR_SELINUX |
89 | char* tar__global_sctx; | 90 | char* tar__global_sctx; |
diff --git a/include/libbb.h b/include/libbb.h index c26012c5d..c371e35f2 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1198,10 +1198,17 @@ char *bb_simplify_path(const char *path) FAST_FUNC; | |||
1198 | /* Returns ptr to NUL */ | 1198 | /* Returns ptr to NUL */ |
1199 | char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC; | 1199 | char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC; |
1200 | 1200 | ||
1201 | #define FAIL_DELAY 3 | 1201 | #define LOGIN_FAIL_DELAY 3 |
1202 | extern void bb_do_delay(int seconds) FAST_FUNC; | 1202 | extern void bb_do_delay(int seconds) FAST_FUNC; |
1203 | extern void change_identity(const struct passwd *pw) FAST_FUNC; | 1203 | extern void change_identity(const struct passwd *pw) FAST_FUNC; |
1204 | extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) NORETURN FAST_FUNC; | 1204 | extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) NORETURN FAST_FUNC; |
1205 | |||
1206 | /* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL. | ||
1207 | * Note that getpwuid result might need xstrdup'ing | ||
1208 | * if there is a possibility of intervening getpwxxx() calls. | ||
1209 | */ | ||
1210 | const char *get_shell_name(void); | ||
1211 | |||
1205 | #if ENABLE_SELINUX | 1212 | #if ENABLE_SELINUX |
1206 | extern void renew_current_security_context(void) FAST_FUNC; | 1213 | extern void renew_current_security_context(void) FAST_FUNC; |
1207 | extern void set_current_security_context(security_context_t sid) FAST_FUNC; | 1214 | extern void set_current_security_context(security_context_t sid) FAST_FUNC; |
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 9d3d9cb4c..0c675caf9 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -132,7 +132,8 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
132 | } | 132 | } |
133 | 133 | ||
134 | pw.pw_gecos = (char *)"Linux User,,,"; | 134 | pw.pw_gecos = (char *)"Linux User,,,"; |
135 | pw.pw_shell = (char *)DEFAULT_SHELL; | 135 | /* We assume that newly created users "inherit" root's shell setting */ |
136 | pw.pw_shell = (char *)get_shell_name(); | ||
136 | pw.pw_dir = NULL; | 137 | pw.pw_dir = NULL; |
137 | 138 | ||
138 | /* exactly one non-option arg */ | 139 | /* exactly one non-option arg */ |
diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 1fdb2fb38..9c5405332 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c | |||
@@ -316,10 +316,8 @@ static NOINLINE void start_shell_in_child(const char* tty_name) | |||
316 | int pid = xvfork(); | 316 | int pid = xvfork(); |
317 | if (pid == 0) { | 317 | if (pid == 0) { |
318 | struct termios termchild; | 318 | struct termios termchild; |
319 | char *shell = getenv("SHELL"); | 319 | const char *shell = get_shell_name(); |
320 | 320 | ||
321 | if (!shell) | ||
322 | shell = (char *) DEFAULT_SHELL; | ||
323 | signal(SIGHUP, SIG_IGN); | 321 | signal(SIGHUP, SIG_IGN); |
324 | // set tty as a controlling tty | 322 | // set tty as a controlling tty |
325 | setsid(); | 323 | setsid(); |
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 163e15dce..16d7fdf69 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -20,8 +20,9 @@ | |||
20 | static void edit_file(const struct passwd *pas, const char *file) | 20 | static void edit_file(const struct passwd *pas, const char *file) |
21 | { | 21 | { |
22 | const char *ptr; | 22 | const char *ptr; |
23 | int pid = xvfork(); | 23 | pid_t pid; |
24 | 24 | ||
25 | pid = xvfork(); | ||
25 | if (pid) { /* parent */ | 26 | if (pid) { /* parent */ |
26 | wait4pid(pid); | 27 | wait4pid(pid); |
27 | return; | 28 | return; |
@@ -30,7 +31,7 @@ static void edit_file(const struct passwd *pas, const char *file) | |||
30 | /* CHILD - change user and run editor */ | 31 | /* CHILD - change user and run editor */ |
31 | /* initgroups, setgid, setuid */ | 32 | /* initgroups, setgid, setuid */ |
32 | change_identity(pas); | 33 | change_identity(pas); |
33 | setup_environment(DEFAULT_SHELL, | 34 | setup_environment(pas->pw_shell, |
34 | SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, | 35 | SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, |
35 | pas); | 36 | pas); |
36 | ptr = getenv("VISUAL"); | 37 | ptr = getenv("VISUAL"); |
@@ -41,7 +42,7 @@ static void edit_file(const struct passwd *pas, const char *file) | |||
41 | } | 42 | } |
42 | 43 | ||
43 | BB_EXECLP(ptr, ptr, file, NULL); | 44 | BB_EXECLP(ptr, ptr, file, NULL); |
44 | bb_perror_msg_and_die("exec %s", ptr); | 45 | bb_perror_msg_and_die("can't execute '%s'", ptr); |
45 | } | 46 | } |
46 | 47 | ||
47 | static int open_as_user(const struct passwd *pas, const char *file) | 48 | static int open_as_user(const struct passwd *pas, const char *file) |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index c7b560bf8..7706a84b7 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -106,6 +106,7 @@ enum { | |||
106 | struct globals { | 106 | struct globals { |
107 | char **my_environ; | 107 | char **my_environ; |
108 | const char *startup_PATH; | 108 | const char *startup_PATH; |
109 | char *shell; | ||
109 | } FIX_ALIASING; | 110 | } FIX_ALIASING; |
110 | #define G (*(struct globals*)&bb_common_bufsiz1) | 111 | #define G (*(struct globals*)&bb_common_bufsiz1) |
111 | #define INIT_G() do { } while (0) | 112 | #define INIT_G() do { } while (0) |
@@ -986,11 +987,10 @@ static int doit(char *str) | |||
986 | 987 | ||
987 | fflush_all(); | 988 | fflush_all(); |
988 | child = vfork(); | 989 | child = vfork(); |
989 | switch (child) { | 990 | if (child < 0) /* failure */ |
990 | case -1: /* failure */ | ||
991 | return 0; | 991 | return 0; |
992 | case 0: /* child */ | 992 | if (child == 0) { /* child */ |
993 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, (char *) NULL, G.my_environ); | 993 | execle(G.shell, G.shell, "-c", str, (char *) NULL, G.my_environ); |
994 | _exit(127); | 994 | _exit(127); |
995 | } | 995 | } |
996 | safe_waitpid(child, &status, 0); | 996 | safe_waitpid(child, &status, 0); |
@@ -1165,6 +1165,7 @@ int ifupdown_main(int argc UNUSED_PARAM, char **argv) | |||
1165 | INIT_G(); | 1165 | INIT_G(); |
1166 | 1166 | ||
1167 | G.startup_PATH = getenv("PATH"); | 1167 | G.startup_PATH = getenv("PATH"); |
1168 | G.shell = xstrdup(get_shell_name()); | ||
1168 | 1169 | ||
1169 | cmds = iface_down; | 1170 | cmds = iface_down; |
1170 | if (applet_name[2] == 'u') { | 1171 | if (applet_name[2] == 'u') { |
diff --git a/runit/svlogd.c b/runit/svlogd.c index cfa20a773..b0ba21bb6 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -187,6 +187,7 @@ struct globals { | |||
187 | unsigned nearest_rotate; | 187 | unsigned nearest_rotate; |
188 | 188 | ||
189 | void* (*memRchr)(const void *, int, size_t); | 189 | void* (*memRchr)(const void *, int, size_t); |
190 | char *shell; | ||
190 | 191 | ||
191 | smallint exitasap; | 192 | smallint exitasap; |
192 | smallint rotateasap; | 193 | smallint rotateasap; |
@@ -382,6 +383,9 @@ static void processorstart(struct logdir *ld) | |||
382 | /* vfork'ed child trashes this byte, save... */ | 383 | /* vfork'ed child trashes this byte, save... */ |
383 | sv_ch = ld->fnsave[26]; | 384 | sv_ch = ld->fnsave[26]; |
384 | 385 | ||
386 | if (!G.shell) | ||
387 | G.shell = xstrdup(get_shell_name()); | ||
388 | |||
385 | while ((pid = vfork()) == -1) | 389 | while ((pid = vfork()) == -1) |
386 | pause2cannot("vfork for processor", ld->name); | 390 | pause2cannot("vfork for processor", ld->name); |
387 | if (!pid) { | 391 | if (!pid) { |
@@ -416,8 +420,7 @@ static void processorstart(struct logdir *ld) | |||
416 | fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); | 420 | fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); |
417 | xmove_fd(fd, 5); | 421 | xmove_fd(fd, 5); |
418 | 422 | ||
419 | // getenv("SHELL")? | 423 | execl(G.shell, G.shell, "-c", ld->processor, (char*) NULL); |
420 | execl(DEFAULT_SHELL, DEFAULT_SHELL_SHORT_NAME, "-c", ld->processor, (char*) NULL); | ||
421 | bb_perror_msg_and_die(FATAL"can't %s processor %s", "run", ld->name); | 424 | bb_perror_msg_and_die(FATAL"can't %s processor %s", "run", ld->name); |
422 | } | 425 | } |
423 | ld->fnsave[26] = sv_ch; /* ...restore */ | 426 | ld->fnsave[26] = sv_ch; /* ...restore */ |
diff --git a/util-linux/script.c b/util-linux/script.c index b9317fc7c..47efc4526 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
@@ -65,10 +65,7 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
65 | if (!(opt & OPT_q)) { | 65 | if (!(opt & OPT_q)) { |
66 | printf("Script started, file is %s\n", fname); | 66 | printf("Script started, file is %s\n", fname); |
67 | } | 67 | } |
68 | shell = getenv("SHELL"); | 68 | shell = get_shell_name(); |
69 | if (shell == NULL) { | ||
70 | shell = DEFAULT_SHELL; | ||
71 | } | ||
72 | 69 | ||
73 | pty = xgetpty(pty_line); | 70 | pty = xgetpty(pty_line); |
74 | 71 | ||