]> git.ipfire.org Git - thirdparty/systemd.git/commit
Rework cmdline printing to use unicode
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 15 May 2019 09:20:26 +0000 (11:20 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 22 May 2019 08:08:17 +0000 (10:08 +0200)
commitbc28751ed2372065fd6f6f7ba6137edf21dee88b
tree22b55bbd88ec30c99aafc0fbb671ce965f621632
parentda88f542d9315a341a500897e5e1bf8809d1aeae
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.
src/basic/proc-cmdline.c
src/basic/process-util.c
src/basic/process-util.h
src/basic/string-util.h
src/core/dbus-unit.c
src/coredump/coredump.c
src/journal/journald-context.c
src/shared/cgroup-show.c
src/shared/cgroup-show.h
src/test/test-process-util.c