[PATCH v2 07/27] crontab: replace BB_EXECLP call with BB_EXECVP

Nadav Tasher tashernadav at gmail.com
Tue Jan 21 22:34:46 UTC 2025


Allows for more control over executed processes,
reduces code duplication by using BB_EXECVP_or_die.

Signed-off-by: Nadav Tasher <tashernadav at gmail.com>
---
 miscutils/crontab.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 1111f4d54..840df5d5d 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -44,6 +44,7 @@ static void edit_file(const struct passwd *pas, const char *file)
 {
 	const char *ptr;
 	pid_t pid;
+	char* edit_argv[3];
 
 	pid = xvfork();
 	if (pid) { /* parent */
@@ -64,8 +65,10 @@ static void edit_file(const struct passwd *pas, const char *file)
 			ptr = "vi";
 	}
 
-	BB_EXECLP(ptr, ptr, file, NULL);
-	bb_perror_msg_and_die("can't execute '%s'", ptr);
+	edit_argv[0] = (char *) ptr;
+	edit_argv[1] = (char *) file;
+	edit_argv[2] = NULL;
+	BB_EXECVP_or_die(edit_argv);
 }
 
 int crontab_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-- 
2.43.0



More information about the busybox mailing list