Branch data Line data Source code
1 : : /* SPDX-License-Identifier: LGPL-2.1+ */
2 : :
3 : : #include "bus-util.h"
4 : : #include "dbus-kill.h"
5 : : #include "dbus-util.h"
6 : : #include "kill.h"
7 : : #include "signal-util.h"
8 : :
9 [ # # # # : 0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode);
# # ]
10 : :
11 : : const sd_bus_vtable bus_kill_vtable[] = {
12 : : SD_BUS_VTABLE_START(0),
13 : : SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), SD_BUS_VTABLE_PROPERTY_CONST),
14 : : SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), SD_BUS_VTABLE_PROPERTY_CONST),
15 : : SD_BUS_PROPERTY("FinalKillSignal", "i", bus_property_get_int, offsetof(KillContext, final_kill_signal), SD_BUS_VTABLE_PROPERTY_CONST),
16 : : SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), SD_BUS_VTABLE_PROPERTY_CONST),
17 : : SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), SD_BUS_VTABLE_PROPERTY_CONST),
18 : : SD_BUS_PROPERTY("WatchdogSignal", "i", bus_property_get_int, offsetof(KillContext, watchdog_signal), SD_BUS_VTABLE_PROPERTY_CONST),
19 : : SD_BUS_VTABLE_END
20 : : };
21 : :
22 [ # # # # : 0 : static BUS_DEFINE_SET_TRANSIENT_PARSE(kill_mode, KillMode, kill_mode_from_string);
# # # # ]
23 [ # # # # : 0 : static BUS_DEFINE_SET_TRANSIENT_TO_STRING(kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check);
# # # # ]
24 [ # # # # : 0 : static BUS_DEFINE_SET_TRANSIENT_TO_STRING(final_kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check);
# # # # ]
25 [ # # # # : 0 : static BUS_DEFINE_SET_TRANSIENT_TO_STRING(watchdog_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check);
# # # # ]
26 : :
27 : 0 : int bus_kill_context_set_transient_property(
28 : : Unit *u,
29 : : KillContext *c,
30 : : const char *name,
31 : : sd_bus_message *message,
32 : : UnitWriteFlags flags,
33 : : sd_bus_error *error) {
34 : :
35 [ # # ]: 0 : assert(u);
36 [ # # ]: 0 : assert(c);
37 [ # # ]: 0 : assert(name);
38 [ # # ]: 0 : assert(message);
39 : :
40 : 0 : flags |= UNIT_PRIVATE;
41 : :
42 [ # # ]: 0 : if (streq(name, "KillMode"))
43 : 0 : return bus_set_transient_kill_mode(u, name, &c->kill_mode, message, flags, error);
44 : :
45 [ # # ]: 0 : if (streq(name, "SendSIGHUP"))
46 : 0 : return bus_set_transient_bool(u, name, &c->send_sighup, message, flags, error);
47 : :
48 [ # # ]: 0 : if (streq(name, "SendSIGKILL"))
49 : 0 : return bus_set_transient_bool(u, name, &c->send_sigkill, message, flags, error);
50 : :
51 [ # # ]: 0 : if (streq(name, "KillSignal"))
52 : 0 : return bus_set_transient_kill_signal(u, name, &c->kill_signal, message, flags, error);
53 : :
54 [ # # ]: 0 : if (streq(name, "FinalKillSignal"))
55 : 0 : return bus_set_transient_final_kill_signal(u, name, &c->final_kill_signal, message, flags, error);
56 : :
57 [ # # ]: 0 : if (streq(name, "WatchdogSignal"))
58 : 0 : return bus_set_transient_watchdog_signal(u, name, &c->watchdog_signal, message, flags, error);
59 : :
60 : 0 : return 0;
61 : : }
|