From: Zbigniew Jędrzejewski-Szmek Date: Fri, 2 Apr 2021 12:11:10 +0000 (+0200) Subject: core,journald: use quoted commandlines X-Git-Tag: v249-rc1~274^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f960b3858eeefb3d27621291b94b72809e288e4;p=thirdparty%2Fsystemd.git core,journald: use quoted commandlines I think quoting is more useful than not quoting. Without, arguments with whitespace cannot be split correctly. Unlike in coredump, "normal" quoting is used in those two cases. This output is mostly for informational purposes, so the more readable quoting seems apropriate. dbus GetProcesses: $ busctl --user call org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/run_2dr4450e1ae73944194bb6593fcfd255fbe_2eservice org.freedesktop.systemd1.Service GetProcesses a(sus) 2 "/user.slice/user-1000.slice/user@1000.service/app.slice/run-r4450e1ae73944194bb6593fcfd255fbe.service" 131494 "/usr/bin/bash -c \"sleep 100; sleep 20\"" "/user.slice/user-1000.slice/user@1000.service/app.slice/run-r4450e1ae73944194bb6593fcfd255fbe.service" 131496 "sleep 100" --- diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 39d6799b59a..53397e8cbf1 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -1229,7 +1229,9 @@ static int append_process(sd_bus_message *reply, const char *p, pid_t pid, Set * p = buf; } - (void) get_process_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_COMM_FALLBACK, &cmdline); + (void) get_process_cmdline(pid, SIZE_MAX, + PROCESS_CMDLINE_COMM_FALLBACK | PROCESS_CMDLINE_QUOTE, + &cmdline); return sd_bus_message_append(reply, "(sus)", diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index add0a5480d5..694056d5589 100644 --- a/src/journal/journald-context.c +++ b/src/journal/journald-context.c @@ -225,7 +225,7 @@ static void client_context_read_basic(ClientContext *c) { if (get_process_exe(c->pid, &t) >= 0) free_and_replace(c->exe, t); - if (get_process_cmdline(c->pid, SIZE_MAX, 0, &t) >= 0) + if (get_process_cmdline(c->pid, SIZE_MAX, PROCESS_CMDLINE_QUOTE, &t) >= 0) free_and_replace(c->cmdline, t); if (get_process_capeff(c->pid, &t) >= 0)