chiark / gitweb /
bus-util: print RestrictNamespaces= as a string
authorDjalal Harouni <tixxdz@opendz.org>
Tue, 15 Nov 2016 14:15:37 +0000 (15:15 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
Allow all callers that want to print RestrictNamespaces= returned from D-Bus
as a string instead of a u64 value.

src/shared/bus-util.c

index 0d64ec196483ecbb2328dc82c7e8576c096d12f1..2d1b3b9654061bbc7fda308ffb0f880b987840de 100644 (file)
@@ -773,6 +773,23 @@ int bus_print_property(const char *name, sd_bus_message *property, bool value, b
                         char timespan[FORMAT_TIMESPAN_MAX];
 
                         print_property(name, "%s", format_timespan(timespan, sizeof(timespan), u, 0));
+                } else if (streq(name, "RestrictNamespaces")) {
+                        _cleanup_free_ char *s = NULL;
+                        const char *result = NULL;
+
+                        if ((u & NAMESPACE_FLAGS_ALL) == 0)
+                                result = "yes";
+                        else if ((u & NAMESPACE_FLAGS_ALL) == NAMESPACE_FLAGS_ALL)
+                                result = "no";
+                        else {
+                                r = namespace_flag_to_string_many(u, &s);
+                                if (r < 0)
+                                        return r;
+
+                                result = s;
+                        }
+
+                        print_property(name, "%s", result);
                 } else
                         print_property(name, "%"PRIu64, u);