summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/busctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 15:59:05 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 16:17:33 +0100
commit3acc1dafd14420872f7f13319260eeb5d62c2533 (patch)
tree376044a15fe091db6e6b712a462b7dfe2c91c582 /src/libsystemd/sd-bus/busctl.c
parent52cfc0379a9d63f99cdb3d9f63c839bbc8889b4c (diff)
sd-bus: add new call sd_bus_get_scope() for querying whether one is connected to a system or a user bus
Diffstat (limited to 'src/libsystemd/sd-bus/busctl.c')
-rw-r--r--src/libsystemd/sd-bus/busctl.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index b4a91dfed3..febfc98a59 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -1193,11 +1193,18 @@ static int status(sd_bus *bus, char *argv[]) {
&creds,
pid,
_SD_BUS_CREDS_ALL);
- } else
+ } else {
+ const char *scope;
+
+ r = sd_bus_get_scope(bus, &scope);
+ if (r >= 0)
+ printf("Scope=%s%s%s\n", ansi_highlight(), scope, ansi_highlight_off());
+
r = sd_bus_get_owner_creds(
bus,
(arg_augment_creds ? SD_BUS_CREDS_AUGMENT : 0) | _SD_BUS_CREDS_ALL,
&creds);
+ }
if (r < 0) {
log_error_errno(r, "Failed to get credentials: %m");
@@ -2006,10 +2013,13 @@ int main(int argc, char *argv[]) {
switch (arg_transport) {
case BUS_TRANSPORT_LOCAL:
- if (arg_user)
+ if (arg_user) {
+ bus->is_user = true;
r = bus_set_address_user(bus);
- else
+ } else {
+ bus->is_system = true;
r = bus_set_address_system(bus);
+ }
break;
case BUS_TRANSPORT_REMOTE: