chiark / gitweb /
shared/bus-util: format uid==-1 and gid==-1 as [not set]
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 25 Sep 2017 09:23:59 +0000 (11:23 +0200)
committerSven Eden <yamakuzure@gmx.net>
Mon, 25 Sep 2017 09:23:59 +0000 (11:23 +0200)
$ systemctl show elogind-journald -p UID,GID
UID=4294967295
GID=4294967295



$ systemctl show elogind-journald -p UID,GID
UID=[not set]
GID=[not set]

Just seeing the number is very misleading.

Fixes #6511.

src/shared/bus-util.c

index 33ab89b2333bd4b304bd17f13ee5052c5cde0865..f3579d07e78796ba752bbe852a7b6b8a27e2670e 100644 (file)
@@ -813,7 +813,17 @@ int bus_print_property(const char *name, sd_bus_message *property, bool value, b
 
                 if (strstr(name, "UMask") || strstr(name, "Mode"))
                         print_property(name, "%04o", u);
-                else
+                else if (streq(name, "UID")) {
+                        if (u == UID_INVALID)
+                                print_property(name, "%s", "[not set]");
+                        else
+                                print_property(name, "%"PRIu32, u);
+                } else if (streq(name, "GID")) {
+                        if (u == GID_INVALID)
+                                print_property(name, "%s", "[not set]");
+                        else
+                                print_property(name, "%"PRIu32, u);
+                } else
                         print_property(name, "%"PRIu32, u);
 
                 return 1;