From: Hilko Bengen Date: Sat, 9 Jan 2021 23:24:53 +0000 (+0100) Subject: output: Replace system() with explicit bash invocation X-Git-Tag: archive/raspbian/1.38.2-2+rpi1~2^2^2^2^2^2^2^2^2^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a5db1fa9053e205d3499f5ffeea555e3eba83cda;p=nbdkit.git output: Replace system() with explicit bash invocation Tehre is probably a better way to do this. Gbp-Pq: Name 0007-output-Replace-system-with-explicit-bash-invocation.patch --- diff --git a/filters/log/output.c b/filters/log/output.c index c999150..89d2eab 100644 --- a/filters/log/output.c +++ b/filters/log/output.c @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -113,6 +114,8 @@ to_script (struct handle *h, log_id_t id, const char *act, enum type type, CLEANUP_FREE char *str = NULL; size_t len = 0; int r; + int pid; + int wstatus = 0; /* Create the shell variables + script. */ fp = open_memstream (&str, &len); @@ -140,7 +143,14 @@ to_script (struct handle *h, log_id_t id, const char *act, enum type type, fclose (fp); /* Run the script. Log the status, but ignore it. */ - r = system (str); + if (pid = fork() == 0) { + execl ("/bin/bash", "sh", "-c", str, NULL); + exit (-errno); + } else if (pid > 0) { + waitpid (pid, &r, 0); + } else { + r = -1; + } exit_status_to_nbd_error (r, "logscript"); }