diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-31 04:54:53 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-31 04:54:53 +0200 |
commit | bf1c344dfdc6f38ad6aa81c10b7b050e0dfc5d96 (patch) | |
tree | d9204645d9623fc0ac92871f7cf78475c4dbef86 /shell | |
parent | 32fdf2f9fc9a617918672d71579f4ad42eb9bde9 (diff) | |
download | busybox-w32-bf1c344dfdc6f38ad6aa81c10b7b050e0dfc5d96.tar.gz busybox-w32-bf1c344dfdc6f38ad6aa81c10b7b050e0dfc5d96.tar.bz2 busybox-w32-bf1c344dfdc6f38ad6aa81c10b7b050e0dfc5d96.zip |
hush: if STANDALONE, close interactive fd for NOEXECed children
function old new delta
pseudo_exec_argv 291 305 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/hush.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index cc785d36b..8e9e0e9e8 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -6803,6 +6803,15 @@ static void restore_redirects(struct squirrel *sq) | |||
6803 | restore_redirected_FILEs(); | 6803 | restore_redirected_FILEs(); |
6804 | } | 6804 | } |
6805 | 6805 | ||
6806 | #if ENABLE_FEATURE_SH_STANDALONE && BB_MMU | ||
6807 | static void close_saved_fds_and_FILE_list(void) | ||
6808 | { | ||
6809 | if (G_interactive_fd) | ||
6810 | close(G_interactive_fd); | ||
6811 | close_all_FILE_list(); | ||
6812 | } | ||
6813 | #endif | ||
6814 | |||
6806 | static int internally_opened_fd(int fd, struct squirrel *sq) | 6815 | static int internally_opened_fd(int fd, struct squirrel *sq) |
6807 | { | 6816 | { |
6808 | int i; | 6817 | int i; |
@@ -7325,8 +7334,12 @@ static NOINLINE void pseudo_exec_argv(nommu_save_t *nommu_save, | |||
7325 | if (a >= 0) { | 7334 | if (a >= 0) { |
7326 | # if BB_MMU /* see above why on NOMMU it is not allowed */ | 7335 | # if BB_MMU /* see above why on NOMMU it is not allowed */ |
7327 | if (APPLET_IS_NOEXEC(a)) { | 7336 | if (APPLET_IS_NOEXEC(a)) { |
7328 | /* Do not leak open fds from opened script files etc */ | 7337 | /* Do not leak open fds from opened script files etc. |
7329 | close_all_FILE_list(); | 7338 | * Testcase: interactive "ls -l /proc/self/fd" |
7339 | * should not show tty fd open. | ||
7340 | */ | ||
7341 | close_saved_fds_and_FILE_list(); | ||
7342 | ///FIXME: should also close saved redir fds | ||
7330 | debug_printf_exec("running applet '%s'\n", argv[0]); | 7343 | debug_printf_exec("running applet '%s'\n", argv[0]); |
7331 | run_applet_no_and_exit(a, argv[0], argv); | 7344 | run_applet_no_and_exit(a, argv[0], argv); |
7332 | } | 7345 | } |