diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-26 01:13:58 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-26 01:13:58 +0100 |
commit | 9967c9949e0436879354e76c2847d697c309984c (patch) | |
tree | dcd6b3707305ef43f496a6058da45c89460fda4e /libbb/vfork_daemon_rexec.c | |
parent | 06f20bf675cdd415c2f796ebea9fc55030ef49cc (diff) | |
download | busybox-w32-9967c9949e0436879354e76c2847d697c309984c.tar.gz busybox-w32-9967c9949e0436879354e76c2847d697c309984c.tar.bz2 busybox-w32-9967c9949e0436879354e76c2847d697c309984c.zip |
libbb: spawn_and_wait() fflushes before forking NOEXEC; child reinits logmode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index c192829b5..2e7dc2d9b 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -183,26 +183,28 @@ int FAST_FUNC spawn_and_wait(char **argv) | |||
183 | #if ENABLE_FEATURE_PREFER_APPLETS | 183 | #if ENABLE_FEATURE_PREFER_APPLETS |
184 | int a = find_applet_by_name(argv[0]); | 184 | int a = find_applet_by_name(argv[0]); |
185 | 185 | ||
186 | if (a >= 0 && (APPLET_IS_NOFORK(a) | 186 | if (a >= 0) { |
187 | # if BB_MMU | ||
188 | || APPLET_IS_NOEXEC(a) /* NOEXEC trick needs fork() */ | ||
189 | # endif | ||
190 | )) { | ||
191 | # if BB_MMU | ||
192 | if (APPLET_IS_NOFORK(a)) | 187 | if (APPLET_IS_NOFORK(a)) |
193 | # endif | ||
194 | { | ||
195 | return run_nofork_applet(a, argv); | 188 | return run_nofork_applet(a, argv); |
189 | # if BB_MMU /* NOEXEC needs fork(), thus this is done only on MMU machines: */ | ||
190 | if (APPLET_IS_NOEXEC(a)) { | ||
191 | fflush_all(); | ||
192 | rc = fork(); | ||
193 | if (rc) /* parent or error */ | ||
194 | return wait4pid(rc); | ||
195 | |||
196 | /* child */ | ||
197 | /* reset some state and run without execing */ | ||
198 | |||
199 | /* msg_eol = "\n"; - no caller needs this reinited yet */ | ||
200 | logmode = LOGMODE_STDIO; | ||
201 | /* die_func = NULL; - needed if the caller is a shell, | ||
202 | * init, or a NOFORK applet. But none of those call us | ||
203 | * as of yet (and that should probably always stay true). | ||
204 | */ | ||
205 | /* xfunc_error_retval and applet_name are init by: */ | ||
206 | run_applet_no_and_exit(a, argv); | ||
196 | } | 207 | } |
197 | # if BB_MMU | ||
198 | /* MMU only */ | ||
199 | /* a->noexec is true */ | ||
200 | rc = fork(); | ||
201 | if (rc) /* parent or error */ | ||
202 | return wait4pid(rc); | ||
203 | /* child */ | ||
204 | xfunc_error_retval = EXIT_FAILURE; | ||
205 | run_applet_no_and_exit(a, argv); | ||
206 | # endif | 208 | # endif |
207 | } | 209 | } |
208 | #endif /* FEATURE_PREFER_APPLETS */ | 210 | #endif /* FEATURE_PREFER_APPLETS */ |