diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-15 11:20:26 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-22 10:08:17 +0200 |
commit | bc28751ed2372065fd6f6f7ba6137edf21dee88b (patch) | |
tree | 22b55bbd88ec30c99aafc0fbb671ce965f621632 /src/core/dbus-unit.c | |
parent | util-lib: add truncation based on printable width to utf8_escape_non_printable() (diff) | |
download | systemd-bc28751ed2372065fd6f6f7ba6137edf21dee88b.tar.xz systemd-bc28751ed2372065fd6f6f7ba6137edf21dee88b.zip |
Rework cmdline printing to use unicode
The functions to retrieve and print process cmdlines were based on the
assumption that they contain printable ASCII, and everything else
should be filtered out. That assumption doesn't hold in today's world,
where people are free to use unicode everywhere.
This replaces the custom cmdline reading code with a more generic approach
using utf8_escape_non_printable_full().
For kernel threads, truncation is done on the parenthesized name, so we'll
get "[worker]", "[worker…]", …, "[w…]", "[…", "…" as we reduce the number of
available columns.
This implementation is most likely slower for very long cmdlines, but I don't
think this is very important. The common case is to have short commandlines,
and should print those properly. Absurdly long cmdlines are the exception,
which needs to be handled correctly and safely, but speed is not too important.
Fixes #12532.
v2:
- use size_t for the number of columns. This change propagates into various
other functions that call get_process_cmdline(), increasing the size of the
patch, but the changes are rather trivial.
Diffstat (limited to 'src/core/dbus-unit.c')
-rw-r--r-- | src/core/dbus-unit.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 16b4a6b133..1e996a2f1b 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -901,7 +901,7 @@ static int append_process(sd_bus_message *reply, const char *p, pid_t pid, Set * p = buf; } - (void) get_process_cmdline(pid, 0, true, &cmdline); + (void) get_process_cmdline(pid, SIZE_MAX, true, &cmdline); return sd_bus_message_append(reply, "(sus)", |