[PATCH 01/18] BB_EXECVP: replace execv and execvp calls with BB_EXECVP
Nadav Tasher
tashernadav at gmail.com
Sun Jan 19 23:10:17 UTC 2025
Change calls from execv and execvp to BB_EXECVP for more
consistency across applets and more control over executed
processes.
Signed-off-by: Nadav Tasher <tashernadav at gmail.com>
---
console-tools/reset.c | 2 +-
debianutils/start_stop_daemon.c | 2 +-
libbb/run_shell.c | 2 +-
networking/ftpd.c | 2 +-
networking/httpd.c | 2 +-
util-linux/switch_root.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/console-tools/reset.c b/console-tools/reset.c
index 655a5ef7a..b2f34a1eb 100644
--- a/console-tools/reset.c
+++ b/console-tools/reset.c
@@ -58,7 +58,7 @@ int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
#else
/* Make sure stdout gets drained before we execvp */
fflush_all();
- execvp("stty", (char**)args);
+ BB_EXECVP("stty", (char**)args);
#endif
}
return EXIT_SUCCESS;
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 271bc4edf..4b42b23a8 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -629,6 +629,6 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
* strace -oLOG start-stop-daemon -S -x /bin/usleep -a qwerty 500000
* should exec "/bin/usleep", but argv[0] should be "qwerty":
*/
- execvp(execname, argv);
+ BB_EXECVP(execname, argv);
bb_perror_msg_and_die("can't execute '%s'", startas);
}
diff --git a/libbb/run_shell.c b/libbb/run_shell.c
index c22bba87b..99184ebe9 100644
--- a/libbb/run_shell.c
+++ b/libbb/run_shell.c
@@ -80,7 +80,7 @@ void FAST_FUNC exec_shell(const char *shell, int loginshell, const char **additi
if (ENABLE_FEATURE_CLEAN_UP)
freecon(current_sid);
#endif
- execv(shell, (char **) args);
+ BB_EXECVP(shell, (char **) args);
bb_perror_msg_and_die("can't execute '%s'", shell);
}
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 0d6a289c7..e4519d25a 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -733,7 +733,7 @@ popen_ls(const char *opt)
}
/* Child expects directory to list on fd #3 */
xmove_fd(cur_fd, 3);
- execv(bb_busybox_exec_path, (char**) argv);
+ BB_EXECVP(argv[0], (char**) argv);
_exit(127);
#endif
}
diff --git a/networking/httpd.c b/networking/httpd.c
index ddcb03bca..f4816ddf5 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1706,7 +1706,7 @@ static void send_cgi_and_exit(
/* _NOT_ execvp. We do not search PATH. argv[0] is a filename
* without any dir components and will only match a file
* in the current directory */
- execv(argv[0], argv);
+ BB_EXECVP(argv[0], argv);
if (verbose)
bb_perror_msg("can't execute '%s'", argv[0]);
error_execing_cgi:
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 14139736e..ec65b35ca 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -281,7 +281,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
return 0;
} else {
// Exec NEW_INIT
- execv(argv[0], argv);
+ BB_EXECVP(argv[0], argv);
}
bb_perror_msg_and_die("can't execute '%s'", argv[0]);
}
--
2.43.0
More information about the busybox
mailing list