chiark / gitweb /
bus-proxy-test: show parsed system/session policy
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Jan 2015 18:30:01 +0000 (19:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 9 Jan 2015 18:30:01 +0000 (19:30 +0100)
src/bus-proxyd/bus-xml-policy.c
src/bus-proxyd/test-bus-xml-policy.c

index 119c731947f06fe4f0e74a93ec18e1c8d4bfc2a9..8d14828a9cb37225d348587909b2a34a68e0934f 100644 (file)
@@ -1047,6 +1047,8 @@ void policy_dump(Policy *p) {
 
         printf("%s Mandatory Items:\n", draw_special_char(DRAW_ARROW));
         dump_items(p->mandatory_items, "\t");
+
+        fflush(stdout);
 }
 
 static const char* const policy_item_type_table[_POLICY_ITEM_TYPE_MAX] = {
index b0f4ed7d3d919fde64a71420d477bd8b25dc7b8f..c22409c0f6a4715224529dd9542297eb1d3adbe7 100644 (file)
@@ -50,17 +50,41 @@ static int test_policy_load(Policy *p, const char *name) {
         assert_se(path);
 
         if (access(path, R_OK) == 0)
-                policy_load(p, STRV_MAKE(path));
+                r = policy_load(p, STRV_MAKE(path));
         else
                 r = -ENOENT;
 
         return r;
 }
 
+static int show_policy(const char *fn) {
+        Policy p = {};
+        int r;
+
+        r = policy_load(&p, STRV_MAKE(fn));
+        if (r < 0) {
+                log_error_errno(r, "Failed to load policy %s: %m", fn);
+                return r;
+        }
+
+        policy_dump(&p);
+        policy_free(&p);
+
+        return 0;
+}
+
 int main(int argc, char *argv[]) {
 
         Policy p = {};
 
+        printf("Showing session policy BEGIN\n");
+        show_policy("/etc/dbus-1/session.conf");
+        printf("Showing session policy END\n");
+
+        printf("Showing system policy BEGIN\n");
+        show_policy("/etc/dbus-1/system.conf");
+        printf("Showing system policy END\n");
+
         /* Ownership tests */
         assert_se(test_policy_load(&p, "ownerships.conf") == 0);