1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2012 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "dbus-kill.h"
26 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode);
28 const sd_bus_vtable bus_kill_vtable[] = {
29 SD_BUS_VTABLE_START(0),
30 SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), SD_BUS_VTABLE_PROPERTY_CONST),
31 SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), SD_BUS_VTABLE_PROPERTY_CONST),
32 SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), SD_BUS_VTABLE_PROPERTY_CONST),
33 SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), SD_BUS_VTABLE_PROPERTY_CONST),
37 int bus_kill_context_set_transient_property(
41 sd_bus_message *message,
42 UnitSetPropertiesMode mode,
43 sd_bus_error *error) {
52 if (streq(name, "KillMode")) {
56 r = sd_bus_message_read(message, "s", &m);
60 k = kill_mode_from_string(m);
64 if (mode != UNIT_CHECK) {
67 unit_write_drop_in_private_format(u, mode, name, "KillMode=%s\n", kill_mode_to_string(k));
72 } else if (streq(name, "KillSignal")) {
75 r = sd_bus_message_read(message, "i", &sig);
79 if (sig <= 0 || sig >= _NSIG)
80 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Signal %i out of range", sig);
82 if (mode != UNIT_CHECK) {
85 unit_write_drop_in_private_format(u, mode, name, "KillSignal=%s\n", signal_to_string(sig));
90 } else if (streq(name, "SendSIGHUP")) {
93 r = sd_bus_message_read(message, "b", &b);
97 if (mode != UNIT_CHECK) {
100 unit_write_drop_in_private_format(u, mode, name, "SendSIGHUP=%s\n", yes_no(b));
105 } else if (streq(name, "SendSIGKILL")) {
108 r = sd_bus_message_read(message, "b", &b);
112 if (mode != UNIT_CHECK) {
115 unit_write_drop_in_private_format(u, mode, name, "SendSIGKILL=%s\n", yes_no(b));