diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-04-02 14:11:10 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-05 13:59:23 +0200 |
commit | 2f960b3858eeefb3d27621291b94b72809e288e4 (patch) | |
tree | 2d8eca66c90730cc3de7561045d1b791ee14c23f | |
parent | 5dd55303f4d7e4294e0d2f1098232bd0fa305832 (diff) | |
download | systemd-2f960b3858eeefb3d27621291b94b72809e288e4.tar.gz |
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"
-rw-r--r-- | src/core/dbus-unit.c | 4 | ||||
-rw-r--r-- | src/journal/journald-context.c | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 39d6799b59..53397e8cbf 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 add0a5480d..694056d558 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) |