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 <tasherna...@gmail.com>
---
 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 eff1bfd6d..387c9324e 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -286,11 +286,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.34.1

_______________________________________________
busybox mailing list
busybox@busybox.net
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to