diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-11-25 02:11:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-11-25 14:28:34 +0100 |
commit | 2e9efd22ce0099c3b4d35898d70f8fc706c8a66c (patch) | |
tree | 5f22100ea552ca449c1d4ea929158337e6f549cf | |
parent | becca6eaafa8ad7771363099f55b8a7dde516f21 (diff) |
busctl: if no parameter is specified for "busctl status" show credentials of bus owner
-rw-r--r-- | man/busctl.xml | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/busctl.c | 27 |
2 files changed, 23 insertions, 11 deletions
diff --git a/man/busctl.xml b/man/busctl.xml index a4c4227d5e..285725e684 100644 --- a/man/busctl.xml +++ b/man/busctl.xml @@ -271,10 +271,13 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. </varlistentry> <varlistentry> - <term><command>status</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg></term> + <term><command>status</command> <arg choice="opt"><replaceable>SERVICE</replaceable></arg></term> <listitem><para>Show process information and credentials of a - bus service.</para></listitem> + bus service (if one is specified by its unique or well-known + name), a process (if one is specified by its numeric PID), or + the owner of the bus (if no parameter is + specified).</para></listitem> </varlistentry> <varlistentry> diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 0795472c8b..50291bafc1 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -1175,20 +1175,29 @@ static int status(sd_bus *bus, char *argv[]) { assert(bus); - if (strv_length(argv) != 2) { - log_error("Expects one argument."); + if (strv_length(argv) > 2) { + log_error("Expects no or one argument."); return -EINVAL; } - r = parse_pid(argv[1], &pid); - if (r < 0) - r = sd_bus_get_name_creds( + if (argv[1]) { + r = parse_pid(argv[1], &pid); + if (r < 0) + r = sd_bus_get_name_creds( + bus, + argv[1], + (arg_augment_creds ? SD_BUS_CREDS_AUGMENT : 0) | _SD_BUS_CREDS_ALL, + &creds); + else + r = sd_bus_creds_new_from_pid( + &creds, + pid, + _SD_BUS_CREDS_ALL); + } else + r = sd_bus_get_owner_creds( bus, - argv[1], (arg_augment_creds ? SD_BUS_CREDS_AUGMENT : 0) | _SD_BUS_CREDS_ALL, &creds); - else - r = sd_bus_creds_new_from_pid(&creds, pid, _SD_BUS_CREDS_ALL); if (r < 0) { log_error("Failed to get credentials: %s", strerror(-r)); @@ -1675,7 +1684,7 @@ static int help(void) { " --augment-creds=BOOL Extend credential data with data read from /proc/$PID\n\n" "Commands:\n" " list List bus names\n" - " status SERVICE Show service name status\n" + " status [SERVICE] Show bus service, process or bus owner credentials\n" " monitor [SERVICE...] Show bus traffic\n" " capture [SERVICE...] Capture bus traffic as pcap\n" " tree [SERVICE...] Show object tree of service\n" |