diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index c9ef662857..9ef3bbf51f 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -15,6 +15,7 @@ #include "cgroup-show.h" #include "cpu-set-util.h" #include "errno-util.h" +#include "escape.h" #include "exec-util.h" #include "exit-status.h" #include "format-util.h" @@ -643,7 +644,8 @@ static void print_status_info( if (endswith(p->name, "Ex")) continue; - argv = strv_join(p->argv, " "); + if (!strv_isempty(p->argv)) + argv = quote_command_line(p->argv, SHELL_ESCAPE_EMPTY); printf(" Process: "PID_FMT" %s=%s ", p->pid, p->name, strna(argv)); good = is_clean_exit(p->code, p->status, EXIT_CLEAN_DAEMON, NULL); diff --git a/test/units/TEST-26-SYSTEMCTL.sh b/test/units/TEST-26-SYSTEMCTL.sh index 75feedd3b0..90084c7f1c 100755 --- a/test/units/TEST-26-SYSTEMCTL.sh +++ b/test/units/TEST-26-SYSTEMCTL.sh @@ -369,6 +369,14 @@ systemctl status "sys-devices-*-ttyS0.device" systemctl status -- -.mount systemctl status 1 +# Exited commands are shown with argument boundaries preserved (#43938) +systemd-run --unit=status-quoting-test.service -p Type=oneshot -p RemainAfterExit=yes \ + --expand-environment=no true "foo bar" "" "a\$b" +output="$(systemctl status --full --no-pager --lines=0 status-quoting-test.service)" +systemctl stop status-quoting-test.service +# shellcheck disable=SC2016 +grep -F ' "foo bar" "" "a\$b" (code=exited, status=0/SUCCESS)' <<<"$output" + # --marked systemctl restart "$UNIT_NAME" systemctl set-property "$UNIT_NAME" "Markers=needs-reload needs-restart"