summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2013-11-17 22:35:58 +0100
committerKay Sievers <kay@vrfy.org>2013-11-17 22:35:58 +0100
commit16be43684f6d9bbd494b157682f5473460fbf98a (patch)
treea3d1280d8c9f8af30fbda78073d2a90d2ddd4eae /src/libsystemd-bus
parent0571a6b0a956a29820ba40a4073565cc3eedaeb0 (diff)
bus: CREDS and NAMES are optional kdbus metadata now
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/kdbus.h5
-rw-r--r--src/libsystemd-bus/libsystemd-bus.sym2
-rw-r--r--src/libsystemd-bus/sd-bus.c18
-rw-r--r--src/libsystemd-bus/test-bus-kernel.c4
4 files changed, 27 insertions, 2 deletions
diff --git a/src/libsystemd-bus/kdbus.h b/src/libsystemd-bus/kdbus.h
index 6015074861..fadb2f2f0c 100644
--- a/src/libsystemd-bus/kdbus.h
+++ b/src/libsystemd-bus/kdbus.h
@@ -237,8 +237,9 @@ enum {
KDBUS_HELLO_STARTER = 1 << 0,
KDBUS_HELLO_ACCEPT_FD = 1 << 1,
- /* The following have an effect on directed messages only --
- * not for broadcasts */
+ /* subscription for metadata to attach */
+ KDBUS_HELLO_ATTACH_CREDS = 1 << 8,
+ KDBUS_HELLO_ATTACH_NAMES = 1 << 9,
KDBUS_HELLO_ATTACH_COMM = 1 << 10,
KDBUS_HELLO_ATTACH_EXE = 1 << 11,
KDBUS_HELLO_ATTACH_CMDLINE = 1 << 12,
diff --git a/src/libsystemd-bus/libsystemd-bus.sym b/src/libsystemd-bus/libsystemd-bus.sym
index f1abf01638..03353f1875 100644
--- a/src/libsystemd-bus/libsystemd-bus.sym
+++ b/src/libsystemd-bus/libsystemd-bus.sym
@@ -26,6 +26,8 @@ global:
sd_bus_set_server;
sd_bus_set_anonymous;
sd_bus_negotiate_fds;
+ sd_bus_negotiate_attach_creds;
+ sd_bus_negotiate_attach_names;
sd_bus_negotiate_attach_comm;
sd_bus_negotiate_attach_exe;
sd_bus_negotiate_attach_cmdline;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 95469d8263..2345c734c3 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -264,6 +264,24 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
return 0;
}
+_public_ int sd_bus_negotiate_attach_creds(sd_bus *bus, int b) {
+ assert_return(bus, -EINVAL);
+ assert_return(bus->state == BUS_UNSET, -EPERM);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_CREDS, b);
+ return 0;
+}
+
+_public_ int sd_bus_negotiate_attach_names(sd_bus *bus, int b) {
+ assert_return(bus, -EINVAL);
+ assert_return(bus->state == BUS_UNSET, -EPERM);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_NAMES, b);
+ return 0;
+}
+
_public_ int sd_bus_negotiate_attach_comm(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus->state == BUS_UNSET, -EPERM);
diff --git a/src/libsystemd-bus/test-bus-kernel.c b/src/libsystemd-bus/test-bus-kernel.c
index 511c547852..05045028b0 100644
--- a/src/libsystemd-bus/test-bus-kernel.c
+++ b/src/libsystemd-bus/test-bus-kernel.c
@@ -62,6 +62,8 @@ int main(int argc, char *argv[]) {
r = sd_bus_set_address(b, address);
assert_se(r >= 0);
+ assert_se(sd_bus_negotiate_attach_creds(a, 1) >= 0);
+ assert_se(sd_bus_negotiate_attach_names(a, 1) >= 0);
assert_se(sd_bus_negotiate_attach_comm(a, 1) >= 0);
assert_se(sd_bus_negotiate_attach_exe(a, 1) >= 0);
assert_se(sd_bus_negotiate_attach_cmdline(a, 1) >= 0);
@@ -70,6 +72,8 @@ int main(int argc, char *argv[]) {
assert_se(sd_bus_negotiate_attach_selinux_context(a, 1) >= 0);
assert_se(sd_bus_negotiate_attach_audit(a, 1) >= 0);
+ assert_se(sd_bus_negotiate_attach_creds(b, 1) >= 0);
+ assert_se(sd_bus_negotiate_attach_names(b, 1) >= 0);
assert_se(sd_bus_negotiate_attach_comm(b, 1) >= 0);
assert_se(sd_bus_negotiate_attach_exe(b, 1) >= 0);
assert_se(sd_bus_negotiate_attach_cmdline(b, 1) >= 0);