chiark / gitweb /
busctl: include connection name in busctl output
authorLennart Poettering <lennart@poettering.net>
Wed, 22 Jan 2014 17:43:03 +0000 (18:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 22 Jan 2014 17:51:49 +0000 (18:51 +0100)
src/libsystemd/sd-bus/bus-dump.c
src/libsystemd/sd-bus/busctl.c

index f1d00a9..a2b6358 100644 (file)
@@ -340,12 +340,16 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f) {
                 fprintf(f, "  Comm=%s", c->comm);
         if (c->mask & SD_BUS_CREDS_TID_COMM)
                 fprintf(f, "  TIDComm=%s", c->tid_comm);
                 fprintf(f, "  Comm=%s", c->comm);
         if (c->mask & SD_BUS_CREDS_TID_COMM)
                 fprintf(f, "  TIDComm=%s", c->tid_comm);
+
+        if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM))
+                fputs("\n", f);
+
         if (c->mask & SD_BUS_CREDS_SELINUX_CONTEXT)
                 fprintf(f, "  Label=%s", c->label);
         if (c->mask & SD_BUS_CREDS_CONNECTION_NAME)
                 fprintf(f, "  ConnectionName=%s", c->conn_name);
 
         if (c->mask & SD_BUS_CREDS_SELINUX_CONTEXT)
                 fprintf(f, "  Label=%s", c->label);
         if (c->mask & SD_BUS_CREDS_CONNECTION_NAME)
                 fprintf(f, "  ConnectionName=%s", c->conn_name);
 
-        if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_SELINUX_CONTEXT|SD_BUS_CREDS_CONNECTION_NAME))
+        if (c->mask & (SD_BUS_CREDS_SELINUX_CONTEXT|SD_BUS_CREDS_CONNECTION_NAME))
                 fputs("\n", f);
 
         if (sd_bus_creds_get_cmdline(c, &cmdline) >= 0) {
                 fputs("\n", f);
 
         if (sd_bus_creds_get_cmdline(c, &cmdline) >= 0) {
index e962ba3..1d7f575 100644 (file)
@@ -106,8 +106,8 @@ static int list_bus_names(sd_bus *bus, char **argv) {
         merged[n] = NULL;
         strv_sort(merged);
 
         merged[n] = NULL;
         strv_sort(merged);
 
-        printf("%-*s %*s %-*s %-*s %-*s %-*s %-*s",
-               (int) max_i, "NAME", 10, "PID", 15, "PROCESS", 16, "USER", 13, "CONNECTION", 25, "UNIT", 10, "SESSION");
+        printf("%-*s %*s %-*s %-*s %-*s %-*s %-*s %-*s",
+               (int) max_i, "NAME", 10, "PID", 15, "PROCESS", 16, "USER", 13, "CONNECTION", 25, "UNIT", 10, "SESSION", 19, "CONNECTION-NAME");
 
         if (arg_show_machine)
                 puts(" MACHINE");
 
         if (arg_show_machine)
                 puts(" MACHINE");
@@ -139,9 +139,12 @@ static int list_bus_names(sd_bus *bus, char **argv) {
 
                 printf("%-*s", (int) max_i, *i);
 
 
                 printf("%-*s", (int) max_i, *i);
 
-                r = sd_bus_get_owner(bus, *i, SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_COMM|SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_SESSION, &creds);
+                r = sd_bus_get_owner(bus, *i,
+                                     SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_COMM|
+                                     SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_SESSION|
+                                     SD_BUS_CREDS_CONNECTION_NAME, &creds);
                 if (r >= 0) {
                 if (r >= 0) {
-                        const char *unique, *session, *unit;
+                        const char *unique, *session, *unit, *cn;
                         pid_t pid;
                         uid_t uid;
 
                         pid_t pid;
                         uid_t uid;
 
@@ -194,8 +197,14 @@ static int list_bus_names(sd_bus *bus, char **argv) {
                         else
                                 fputs(" -         ", stdout);
 
                         else
                                 fputs(" -         ", stdout);
 
+                        r = sd_bus_creds_get_connection_name(creds, &cn);
+                        if (r >= 0)
+                                printf(" %-19s", cn);
+                        else
+                                fputs(" -                  ", stdout);
+
                 } else
                 } else
-                        printf("          - -               -                -             -                         -         ");
+                        printf("          - -               -                -             -                         -          -                  ");
 
                 if (arg_show_machine) {
                         r = sd_bus_get_owner_machine_id(bus, *i, &mid);
 
                 if (arg_show_machine) {
                         r = sd_bus_get_owner_machine_id(bus, *i, &mid);