[systemd-commits] 2 commits - src/libsystemd
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Jan 22 09:51:57 PST 2014
src/libsystemd/sd-bus/bus-creds.c | 10 +++++++++-
src/libsystemd/sd-bus/bus-creds.h | 2 +-
src/libsystemd/sd-bus/bus-dump.c | 6 +++++-
src/libsystemd/sd-bus/busctl.c | 19 ++++++++++++++-----
4 files changed, 29 insertions(+), 8 deletions(-)
New commits:
commit 14008e4e9cc6b51d68cd07ed091f788239d92856
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 22 18:43:03 2014 +0100
busctl: include connection name in busctl output
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index f1d00a9..a2b6358 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -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);
+
+ 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_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) {
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index e962ba3..1d7f575 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -106,8 +106,8 @@ static int list_bus_names(sd_bus *bus, char **argv) {
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");
@@ -139,9 +139,12 @@ static int list_bus_names(sd_bus *bus, char **argv) {
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) {
- const char *unique, *session, *unit;
+ const char *unique, *session, *unit, *cn;
pid_t pid;
uid_t uid;
@@ -194,8 +197,14 @@ static int list_bus_names(sd_bus *bus, char **argv) {
else
fputs(" - ", stdout);
+ r = sd_bus_creds_get_connection_name(creds, &cn);
+ if (r >= 0)
+ printf(" %-19s", cn);
+ else
+ fputs(" - ", stdout);
+
} else
- printf(" - - - - - - ");
+ printf(" - - - - - - - ");
if (arg_show_machine) {
r = sd_bus_get_owner_machine_id(bus, *i, &mid);
commit 2578d51ebd40ae0a8c6343164334358384dd55f7
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 22 18:45:38 2014 +0100
bus: unescape connection name when reading it from credentials
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 85509e8..677e94b 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -48,6 +48,7 @@ void bus_creds_done(sd_bus_creds *c) {
free(c->unit);
free(c->user_unit);
free(c->slice);
+ free(c->unescaped_conn_name);
strv_free(c->cmdline_array);
strv_free(c->well_known_names);
@@ -471,7 +472,14 @@ _public_ int sd_bus_creds_get_connection_name(sd_bus_creds *c, const char **ret)
return -ENODATA;
assert(c->conn_name);
- *ret = c->conn_name;
+
+ if (!c->unescaped_conn_name) {
+ c->unescaped_conn_name = sd_bus_label_unescape(c->conn_name);
+ if (!c->unescaped_conn_name)
+ return -ENOMEM;
+ }
+
+ *ret = c->unescaped_conn_name;
return 0;
}
diff --git a/src/libsystemd/sd-bus/bus-creds.h b/src/libsystemd/sd-bus/bus-creds.h
index df33d34..81b852a 100644
--- a/src/libsystemd/sd-bus/bus-creds.h
+++ b/src/libsystemd/sd-bus/bus-creds.h
@@ -65,7 +65,7 @@ struct sd_bus_creds {
char *cgroup_root;
- char *conn_name;
+ char *conn_name, *unescaped_conn_name;
};
sd_bus_creds* bus_creds_new(void);
More information about the systemd-commits
mailing list