summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-bus/bus-internal.h1
-rw-r--r--src/libsystemd-bus/bus-kernel.c1
-rw-r--r--src/libsystemd-bus/bus-socket.c2
-rw-r--r--src/libsystemd-bus/kdbus.h30
-rw-r--r--src/libsystemd-bus/sd-bus.c21
5 files changed, 32 insertions, 23 deletions
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index accb83849b..9c9e142a5b 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -239,6 +239,7 @@ struct sd_bus {
pid_t original_pid;
uint64_t hello_flags;
+ uint64_t attach_flags;
uint64_t match_cookie;
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index 08f1851b96..959392a62d 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -326,6 +326,7 @@ int bus_kernel_take_fd(sd_bus *b) {
zero(hello);
hello.size = sizeof(hello);
hello.conn_flags = b->hello_flags;
+ hello.attach_flags = b->attach_flags;
hello.pool_size = KDBUS_POOL_SIZE;
r = ioctl(b->input_fd, KDBUS_CMD_HELLO, &hello);
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index 60d9ad41c3..6845f9d1bb 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -611,7 +611,7 @@ int bus_socket_setup(sd_bus *b) {
enable = !b->bus_client;
setsockopt(b->input_fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable));
- enable = !b->bus_client && (b->hello_flags & KDBUS_HELLO_ATTACH_SECLABEL);
+ enable = !b->bus_client && (b->attach_flags & KDBUS_ATTACH_SECLABEL);
setsockopt(b->input_fd, SOL_SOCKET, SO_PASSSEC, &enable, sizeof(enable));
/* Increase the buffers to a MB */
diff --git a/src/libsystemd-bus/kdbus.h b/src/libsystemd-bus/kdbus.h
index 3d21689bb6..52085b92c9 100644
--- a/src/libsystemd-bus/kdbus.h
+++ b/src/libsystemd-bus/kdbus.h
@@ -236,18 +236,20 @@ struct kdbus_cmd_policy {
enum {
KDBUS_HELLO_STARTER = 1 << 0,
KDBUS_HELLO_ACCEPT_FD = 1 << 1,
+};
- /* subscription for metadata to attach */
- KDBUS_HELLO_ATTACH_TIMESTAMP = 1 << 8,
- KDBUS_HELLO_ATTACH_CREDS = 1 << 9,
- KDBUS_HELLO_ATTACH_NAMES = 1 << 10,
- KDBUS_HELLO_ATTACH_COMM = 1 << 11,
- KDBUS_HELLO_ATTACH_EXE = 1 << 12,
- KDBUS_HELLO_ATTACH_CMDLINE = 1 << 13,
- KDBUS_HELLO_ATTACH_CGROUP = 1 << 14,
- KDBUS_HELLO_ATTACH_CAPS = 1 << 15,
- KDBUS_HELLO_ATTACH_SECLABEL = 1 << 16,
- KDBUS_HELLO_ATTACH_AUDIT = 1 << 17,
+/* Flags for message attachments */
+enum {
+ KDBUS_ATTACH_TIMESTAMP = 1 << 0,
+ KDBUS_ATTACH_CREDS = 1 << 1,
+ KDBUS_ATTACH_NAMES = 1 << 2,
+ KDBUS_ATTACH_COMM = 1 << 3,
+ KDBUS_ATTACH_EXE = 1 << 4,
+ KDBUS_ATTACH_CMDLINE = 1 << 5,
+ KDBUS_ATTACH_CGROUP = 1 << 6,
+ KDBUS_ATTACH_CAPS = 1 << 7,
+ KDBUS_ATTACH_SECLABEL = 1 << 8,
+ KDBUS_ATTACH_AUDIT = 1 << 9,
};
struct kdbus_cmd_hello {
@@ -260,6 +262,9 @@ struct kdbus_cmd_hello {
* more. Kernel might refuse client's
* capabilities by returning an error
* from KDBUS_HELLO */
+ __u64 attach_flags; /* userspace specifies the metadata
+ * attachments it wishes to receive with
+ * every message. */
/* kernel → userspace */
__u64 bus_flags; /* this is .flags copied verbatim from
@@ -366,7 +371,8 @@ enum {
struct kdbus_cmd_name_info {
__u64 size; /* overall size of info */
- __u64 flags;
+ __u64 flags; /* query flags */
+ __u64 attach_flags; /* which meta data payload to attach */
__u64 id; /* either ID, or 0 and _ITEM_NAME follows */
struct kdbus_creds creds;
struct kdbus_item items[0]; /* list of item records */
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 97a8c683bb..2fe6340e36 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -181,7 +181,8 @@ _public_ int sd_bus_new(sd_bus **ret) {
r->n_ref = REFCNT_INIT;
r->input_fd = r->output_fd = -1;
r->message_version = 1;
- r->hello_flags |= KDBUS_HELLO_ACCEPT_FD|KDBUS_HELLO_ATTACH_NAMES;
+ r->hello_flags |= KDBUS_HELLO_ACCEPT_FD;
+ r->attach_flags |= KDBUS_ATTACH_NAMES;
r->original_pid = getpid();
assert_se(pthread_mutex_init(&r->memfd_cache_mutex, NULL) == 0);
@@ -279,7 +280,7 @@ _public_ int sd_bus_negotiate_attach_timestamp(sd_bus *bus, int b) {
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_TIMESTAMP, b);
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_TIMESTAMP, b);
return 0;
}
@@ -289,28 +290,28 @@ _public_ int sd_bus_negotiate_attach_creds(sd_bus *bus, uint64_t mask) {
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_CREDS,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_CREDS,
!!(mask & (SD_BUS_CREDS_UID|SD_BUS_CREDS_GID|SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID)));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_COMM,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_COMM,
!!(mask & (SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM)));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_EXE,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_EXE,
!!(mask & SD_BUS_CREDS_EXE));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_CMDLINE,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_CMDLINE,
!!(mask & SD_BUS_CREDS_CMDLINE));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_CGROUP,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_CGROUP,
!!(mask & (SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_CREDS_OWNER_UID)));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_CAPS,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_CAPS,
!!(mask & (SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS)));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_SECLABEL,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_SECLABEL,
!!(mask & SD_BUS_CREDS_SELINUX_CONTEXT));
- SET_FLAG(bus->hello_flags, KDBUS_HELLO_ATTACH_AUDIT,
+ SET_FLAG(bus->attach_flags, KDBUS_ATTACH_AUDIT,
!!(mask & (SD_BUS_CREDS_AUDIT_SESSION_ID|SD_BUS_CREDS_AUDIT_LOGIN_UID)));
bus->creds_mask = mask;