[PATCH v8 08/14] applets: change system() calls to bb_system()

Nadav Tasher tashernadav at gmail.com
Sun Mar 9 23:55:30 UTC 2025


Allows for execution of the internal shell when the
FEATURE_PREFER_APPLETS configuration option is enabled..

Signed-off-by: Nadav Tasher <tashernadav at gmail.com>
---
 archival/dpkg.c       | 2 +-
 editors/awk.c         | 2 +-
 editors/vi.c          | 2 +-
 init/bootchartd.c     | 2 +-
 miscutils/man.c       | 2 +-
 networking/slattach.c | 2 +-
 procps/watch.c        | 2 +-
 util-linux/mdev.c     | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/archival/dpkg.c b/archival/dpkg.c
index 8031956e9..214c49734 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1268,7 +1268,7 @@ static void run_package_script_or_die(const char *package_name, const char *scri
 	script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
 
 	/* If the file doesn't exist it isn't fatal */
-	result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
+	result = access(script_path, F_OK) ? EXIT_SUCCESS : bb_system(script_path);
 	free(script_path);
 	if (result)
 		bb_error_msg_and_die("%s failed, exit code %d", script_type, result);
diff --git a/editors/awk.c b/editors/awk.c
index 64e752f4b..9bc5e5c6b 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -3479,7 +3479,7 @@ static var *evaluate(node *op, var *res)
 			case F_sy:
 				fflush_all();
 				R_d = (ENABLE_FEATURE_ALLOW_EXEC && L.s && *L.s)
-						? (system(L.s) >> 8) : 0;
+						? (bb_system(L.s) >> 8) : 0;
 				break;
 
 			case F_ff:
diff --git a/editors/vi.c b/editors/vi.c
index 34932f60c..e27b1604f 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2956,7 +2956,7 @@ static void colon(char *buf)
 			goto ret;
 		go_bottom_and_clear_to_eol();
 		cookmode();
-		retcode = system(exp);	// run the cmd
+		retcode = bb_system(exp);	// run the cmd
 		if (retcode)
 			printf("\nshell returned %i\n\n", retcode);
 		rawmode();
diff --git a/init/bootchartd.c b/init/bootchartd.c
index 0929890a3..f23025fbf 100644
--- a/init/bootchartd.c
+++ b/init/bootchartd.c
@@ -315,7 +315,7 @@ static void finalize(char *tempdir, const char *prog, int process_accounting)
 	fclose(header_fp);
 
 	/* Package log files */
-	system(xasprintf("tar -zcf /var/log/bootlog.tgz header %s *.log", process_accounting ? "kernel_pacct" : ""));
+	bb_system(xasprintf("tar -zcf /var/log/bootlog.tgz header %s *.log", process_accounting ? "kernel_pacct" : ""));
 	/* Clean up (if we are not in detached tmpfs) */
 	if (tempdir) {
 		unlink("header");
diff --git a/miscutils/man.c b/miscutils/man.c
index deaf9e5ab..f0033ebde 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -157,7 +157,7 @@ static int run_pipe(char *man_filename, int man, int level)
 	} else {
 		cmd = xstrdup(G.pager);
 	}
-	system(cmd);
+	bb_system(cmd);
 	free(cmd);
 	return 1;
 }
diff --git a/networking/slattach.c b/networking/slattach.c
index 2f5cd15ab..2a37ee5de 100644
--- a/networking/slattach.c
+++ b/networking/slattach.c
@@ -222,7 +222,7 @@ int slattach_main(int argc UNUSED_PARAM, char **argv)
 
 	/* Execute command on hangup */
 	if (opt & OPT_c_extcmd)
-		system(extcmd);
+		bb_system(extcmd);
 
 	/* Restore states and exit */
 	restore_state_and_exit(EXIT_SUCCESS);
diff --git a/procps/watch.c b/procps/watch.c
index 05b72723c..00f3158b7 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -112,7 +112,7 @@ int watch_main(int argc UNUSED_PARAM, char **argv)
 		// TODO: 'real' watch pipes cmd's output to itself
 		// and does not allow it to overflow the screen
 		// (taking into account linewrap!)
-		system(cmd);
+		bb_system(cmd);
 		sleep_for_duration(period);
 	}
 	return 0; // gcc thinks we can reach this :)
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index e98d46743..bbf1eff1b 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -804,7 +804,7 @@ static void make_device(char *device_name, char *path, int operation)
 			char *s = xasprintf("%s=%s", "MDEV", node_name);
 			putenv(s);
 			dbg1("running: %s", command);
-			if (system(command) == -1)
+			if (bb_system(command) == -1)
 				bb_perror_msg("can't run '%s'", command);
 			bb_unsetenv_and_free(s);
 		}
-- 
2.43.0



More information about the busybox mailing list