summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-kernel.c
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-11-29 17:21:39 +0100
committerDaniel Mack <zonque@gmail.com>2013-11-29 22:01:34 +0100
commit87b522ae1936c4da9446ee2e05f7b4560ad549cd (patch)
tree7685695aeda7edc92b41791cf61b6c6611f11dde /src/libsystemd-bus/bus-kernel.c
parentc931748d20ba75e062b6198721970c6871bf23da (diff)
libsystemd-bus: add sd_bus_translate_attach_flags()
Factor out code from sd_bus_negotiate_attach_creds() to a generic translate function, so it can be used from other places.
Diffstat (limited to 'src/libsystemd-bus/bus-kernel.c')
-rw-r--r--src/libsystemd-bus/bus-kernel.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index 1b586d81d0..1b54ba5d5b 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -566,6 +566,39 @@ static int bus_kernel_translate_message(sd_bus *bus, struct kdbus_msg *k, sd_bus
return translate[found->type](bus, k, d, ret);
}
+int kdbus_translate_attach_flags(uint64_t mask, uint64_t *kdbus_mask) {
+
+ uint64_t m = 0;
+
+ SET_FLAG(m, 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(m, KDBUS_ATTACH_COMM,
+ !!(mask & (SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM)));
+
+ SET_FLAG(m, KDBUS_ATTACH_EXE,
+ !!(mask & SD_BUS_CREDS_EXE));
+
+ SET_FLAG(m, KDBUS_ATTACH_CMDLINE,
+ !!(mask & SD_BUS_CREDS_CMDLINE));
+
+ SET_FLAG(m, 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(m, 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(m, KDBUS_ATTACH_SECLABEL,
+ !!(mask & SD_BUS_CREDS_SELINUX_CONTEXT));
+
+ SET_FLAG(m, KDBUS_ATTACH_AUDIT,
+ !!(mask & (SD_BUS_CREDS_AUDIT_SESSION_ID|SD_BUS_CREDS_AUDIT_LOGIN_UID)));
+
+ *kdbus_mask = m;
+
+ return 0;
+}
+
static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_message **ret) {
sd_bus_message *m = NULL;
struct kdbus_item *d;