summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd-bus/bus-control.c2
-rw-r--r--src/libsystemd-bus/bus-creds.c2
-rw-r--r--src/libsystemd-bus/busctl.c30
-rw-r--r--src/libsystemd-bus/sd-bus.c4
-rw-r--r--src/libsystemd-bus/test-bus-creds.c4
-rw-r--r--src/libsystemd-bus/test-bus-kernel.c4
-rw-r--r--src/systemd/sd-bus.h2
7 files changed, 38 insertions, 10 deletions
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
index 4f8c623632..77c45432b7 100644
--- a/src/libsystemd-bus/bus-control.c
+++ b/src/libsystemd-bus/bus-control.c
@@ -598,7 +598,7 @@ _public_ int sd_bus_get_owner(
assert_return(bus, -EINVAL);
assert_return(name, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_MAX, -ENOTSUP);
+ assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP);
assert_return(mask == 0 || creds, -EINVAL);
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
diff --git a/src/libsystemd-bus/bus-creds.c b/src/libsystemd-bus/bus-creds.c
index 54dcd41b14..6071312730 100644
--- a/src/libsystemd-bus/bus-creds.c
+++ b/src/libsystemd-bus/bus-creds.c
@@ -126,7 +126,7 @@ _public_ int sd_bus_creds_new_from_pid(pid_t pid, uint64_t mask, sd_bus_creds **
int r;
assert_return(pid >= 0, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_MAX, -ENOTSUP);
+ assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP);
assert_return(ret, -EINVAL);
if (pid == 0)
diff --git a/src/libsystemd-bus/busctl.c b/src/libsystemd-bus/busctl.c
index f557e50036..f1ae051c9b 100644
--- a/src/libsystemd-bus/busctl.c
+++ b/src/libsystemd-bus/busctl.c
@@ -215,8 +215,33 @@ static int monitor(sd_bus *bus, char *argv[]) {
return r;
}
}
+}
- return -EINVAL;
+static int status(sd_bus *bus, char *argv[]) {
+ _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
+ pid_t pid;
+ int r;
+
+ assert(bus);
+
+ if (strv_length(argv) != 2) {
+ log_error("Expects one argument.");
+ return -EINVAL;
+ }
+
+ r = parse_pid(argv[1], &pid);
+ if (r < 0)
+ r = sd_bus_get_owner(bus, argv[1], _SD_BUS_CREDS_ALL, &creds);
+ else
+ r = sd_bus_creds_new_from_pid(pid, _SD_BUS_CREDS_ALL, &creds);
+
+ if (r < 0) {
+ log_error("Failed to get credentials: %s", strerror(-r));
+ return r;
+ }
+
+ bus_creds_dump(creds, NULL);
+ return 0;
}
static int help(void) {
@@ -347,6 +372,9 @@ static int busctl_main(sd_bus *bus, int argc, char *argv[]) {
if (streq(argv[optind], "monitor"))
return monitor(bus, argv + optind);
+ if (streq(argv[optind], "status"))
+ return status(bus, argv + optind);
+
if (streq(argv[optind], "help"))
return help();
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 1ed08c0f9e..a86e33ce27 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -287,7 +287,7 @@ _public_ int sd_bus_negotiate_attach_timestamp(sd_bus *bus, int b) {
_public_ int sd_bus_negotiate_attach_creds(sd_bus *bus, uint64_t mask) {
assert_return(bus, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_MAX, -EINVAL);
+ assert_return(mask <= _SD_BUS_CREDS_ALL, -EINVAL);
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
@@ -2797,7 +2797,7 @@ _public_ int sd_bus_get_peer_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **re
int r;
assert_return(bus, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_MAX, -ENOTSUP);
+ assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP);
assert_return(ret, -EINVAL);
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
diff --git a/src/libsystemd-bus/test-bus-creds.c b/src/libsystemd-bus/test-bus-creds.c
index 0a9b2ca466..966b84c39e 100644
--- a/src/libsystemd-bus/test-bus-creds.c
+++ b/src/libsystemd-bus/test-bus-creds.c
@@ -28,14 +28,14 @@ int main(int argc, char *argv[]) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
int r;
- r = sd_bus_creds_new_from_pid(0, _SD_BUS_CREDS_MAX, &creds);
+ r = sd_bus_creds_new_from_pid(0, _SD_BUS_CREDS_ALL, &creds);
assert_se(r >= 0);
bus_creds_dump(creds, NULL);
creds = sd_bus_creds_unref(creds);
- r = sd_bus_creds_new_from_pid(1, _SD_BUS_CREDS_MAX, &creds);
+ r = sd_bus_creds_new_from_pid(1, _SD_BUS_CREDS_ALL, &creds);
if (r != -EACCES) {
assert_se(r >= 0);
putchar('\n');
diff --git a/src/libsystemd-bus/test-bus-kernel.c b/src/libsystemd-bus/test-bus-kernel.c
index 23b185d3fe..785e2450bf 100644
--- a/src/libsystemd-bus/test-bus-kernel.c
+++ b/src/libsystemd-bus/test-bus-kernel.c
@@ -64,10 +64,10 @@ int main(int argc, char *argv[]) {
assert_se(r >= 0);
assert_se(sd_bus_negotiate_attach_timestamp(a, 1) >= 0);
- assert_se(sd_bus_negotiate_attach_creds(a, _SD_BUS_CREDS_MAX) >= 0);
+ assert_se(sd_bus_negotiate_attach_creds(a, _SD_BUS_CREDS_ALL) >= 0);
assert_se(sd_bus_negotiate_attach_timestamp(b, 1) >= 0);
- assert_se(sd_bus_negotiate_attach_creds(b, _SD_BUS_CREDS_MAX) >= 0);
+ assert_se(sd_bus_negotiate_attach_creds(b, _SD_BUS_CREDS_ALL) >= 0);
r = sd_bus_start(a);
assert_se(r >= 0);
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 1cce9c59b9..2598d7ef97 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -72,7 +72,7 @@ enum {
SD_BUS_CREDS_AUDIT_LOGIN_UID = 1ULL << 21,
SD_BUS_CREDS_UNIQUE_NAME = 1ULL << 22,
SD_BUS_CREDS_WELL_KNOWN_NAMES = 1ULL << 23,
- _SD_BUS_CREDS_MAX = (1ULL << 24) -1,
+ _SD_BUS_CREDS_ALL = (1ULL << 24) -1,
};
/* Callbacks */