diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-19 21:12:59 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-20 20:52:36 +0100 |
commit | 718db96199eb307751264e4163555662c9a389fa (patch) | |
tree | 9ec8467596ba1acba76bb6273c7797baf68c1a00 /src/core/dbus-kill.c | |
parent | 3febea3a0b0a968ea281e7959c1654cbaf95c9bf (diff) |
core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.
This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:
- Synthesizing of "Disconnected" messages when bus connections are
severed.
- Support for attaching multiple vtables for the same interface on the
same path.
This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.
As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
Diffstat (limited to 'src/core/dbus-kill.c')
-rw-r--r-- | src/core/dbus-kill.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/core/dbus-kill.c b/src/core/dbus-kill.c index 811adb1b5a..42488b1f54 100644 --- a/src/core/dbus-kill.c +++ b/src/core/dbus-kill.c @@ -19,43 +19,44 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <errno.h> -#include <dbus/dbus.h> - +#include "bus-util.h" +#include "kill.h" #include "dbus-kill.h" -#include "dbus-common.h" +#include "bus-util.h" -static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_kill_append_mode, kill_mode, KillMode); +static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode); -const BusProperty bus_kill_context_properties[] = { - { "KillMode", bus_kill_append_mode, "s", offsetof(KillContext, kill_mode) }, - { "KillSignal", bus_property_append_int, "i", offsetof(KillContext, kill_signal) }, - { "SendSIGKILL", bus_property_append_bool, "b", offsetof(KillContext, send_sigkill) }, - { "SendSIGHUP", bus_property_append_bool, "b", offsetof(KillContext, send_sighup) }, - {} +const sd_bus_vtable bus_kill_vtable[] = { + SD_BUS_VTABLE_START(0), + SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), 0), + SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), 0), + SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), 0), + SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), 0), + SD_BUS_VTABLE_END }; int bus_kill_context_set_transient_property( Unit *u, KillContext *c, const char *name, - DBusMessageIter *i, + sd_bus_message *message, UnitSetPropertiesMode mode, - DBusError *error) { + sd_bus_error *error) { + + int r; assert(u); assert(c); assert(name); - assert(i); + assert(message); if (streq(name, "KillMode")) { const char *m; KillMode k; - if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_STRING) - return -EINVAL; - - dbus_message_iter_get_basic(i, &m); + r = sd_bus_message_read(message, "s", &m); + if (r < 0) + return r; k = kill_mode_from_string(m); if (k < 0) @@ -70,14 +71,13 @@ int bus_kill_context_set_transient_property( return 1; } else if (streq(name, "SendSIGHUP")) { + int b; - if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) - return -EINVAL; + r = sd_bus_message_read(message, "b", &b); + if (r < 0) + return r; if (mode != UNIT_CHECK) { - dbus_bool_t b; - - dbus_message_iter_get_basic(i, &b); c->send_sighup = b; unit_write_drop_in_private_format(u, mode, name, "SendSIGHUP=%s\n", yes_no(b)); @@ -86,14 +86,13 @@ int bus_kill_context_set_transient_property( return 1; } else if (streq(name, "SendSIGKILL")) { + int b; - if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) - return -EINVAL; + r = sd_bus_message_read(message, "b", &b); + if (r < 0) + return r; if (mode != UNIT_CHECK) { - dbus_bool_t b; - - dbus_message_iter_get_basic(i, &b); c->send_sigkill = b; unit_write_drop_in_private_format(u, mode, name, "SendSIGKILL=%s\n", yes_no(b)); |