]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
inhibit: cut off overly long "who" fields 18518/head
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Feb 2021 14:03:46 +0000 (15:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Feb 2021 14:06:25 +0000 (15:06 +0100)
systemd-inhibit when invoked with a command line will put the whole
command line in the "who" field of the inhibitor lock. This can get
extremely long for shell expressions, making the table "systemd-inhibit
--list" shows ridiculously weirdly formatted. Let's put a limit on the
column width: half of the screen, not more.

src/login/inhibit.c

index afb4d7e2e1f9eb65380066a7f27a4df6a379f4a9..20685c18a30643a9c3a824c56ee498289d87f62d 100644 (file)
@@ -90,6 +90,7 @@ static int print_inhibitors(sd_bus *bus) {
 
         /* If there's not enough space, shorten the "WHY" column, as it's little more than an explaining comment. */
         (void) table_set_weight(table, TABLE_HEADER_CELL(6), 20);
+        (void) table_set_maximum_width(table, TABLE_HEADER_CELL(0), columns()/2);
 
         r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)");
         if (r < 0)