[systemd-devel] [PATCH] export SELinuxContext on the bus as a structure
Michael Scherer
misc at zarb.org
Fri Feb 14 08:13:50 PST 2014
This permit to hide the logic of prefixing by '-' from the consumer
of the DBus API, by presenting a boolean and a string rather than just
a raw string, with specific magic value. See http://lists.freedesktop.org/archives/systemd-devel/2014-February/016918.html
---
src/core/dbus-execute.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index a62f517..559aa63 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -75,6 +75,25 @@ static int property_get_environment_files(
return sd_bus_message_close_container(reply);
}
+static int property_get_ignorable_property(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ char *c = userdata;
+
+ assert(bus);
+ assert(reply);
+ assert(c);
+
+ return sd_bus_message_append(reply, "(bs)", c[0] == '-', c[0] == '-' ? c + 1 : c);
+}
+
+
static int property_get_rlimit(
sd_bus *bus,
const char *path,
@@ -523,7 +542,7 @@ const sd_bus_vtable bus_exec_vtable[] = {
SD_BUS_PROPERTY("PrivateDevices", "b", bus_property_get_bool, offsetof(ExecContext, private_devices), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SameProcessGroup", "b", bus_property_get_bool, offsetof(ExecContext, same_pgrp), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("UtmpIdentifier", "s", NULL, offsetof(ExecContext, utmp_id), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("SELinuxContext", "s", NULL, offsetof(ExecContext, selinux_context), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("SELinuxContext", "(bs)", property_get_ignorable_property, offsetof(ExecContext, selinux_context), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("IgnoreSIGPIPE", "b", bus_property_get_bool, offsetof(ExecContext, ignore_sigpipe), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("NoNewPrivileges", "b", bus_property_get_bool, offsetof(ExecContext, no_new_privileges), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SystemCallFilter", "(bas)", property_get_syscall_filter, 0, SD_BUS_VTABLE_PROPERTY_CONST),
--
1.8.5.3
More information about the systemd-devel
mailing list