By using bb_execv, an applet can be executed with NOEXEC instead of actually re-executing the binary, which might not work in scenareos where busybox is embedded into another binary.
Signed-off-by: Nadav Tasher <[email protected]> --- libbb/vfork_daemon_rexec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index e46536043..7a8d22f97 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c @@ -288,11 +288,16 @@ int FAST_FUNC bb_system(const char *command) { #if !BB_MMU void FAST_FUNC re_exec(char **argv) { + /* create a copy of argv[0], we'll use it for exec */ + char *name = xstrdup(argv[0]); + /* high-order bit of first char in argv[0] is a hidden * "we have (already) re-execed, don't do it again" flag */ argv[0][0] |= 0x80; - execv(bb_busybox_exec_path, argv); - bb_perror_msg_and_die("can't execute '%s'", bb_busybox_exec_path); + + /* if required, bb_execvp with re-exec bb_busybox_exec_path */ + bb_execv(name, argv); + bb_perror_msg_and_die("can't execute '%s'", name); } pid_t FAST_FUNC fork_or_rexec(char **argv) -- 2.43.0 _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
