]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
4819ff03 | 2 | |
24882e06 | 3 | #include "bus-util.h" |
4819ff03 | 4 | #include "dbus-kill.h" |
88629599 | 5 | #include "dbus-util.h" |
cf0fbc49 TA |
6 | #include "kill.h" |
7 | #include "signal-util.h" | |
4819ff03 | 8 | |
718db961 | 9 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode); |
4819ff03 | 10 | |
718db961 LP |
11 | const sd_bus_vtable bus_kill_vtable[] = { |
12 | SD_BUS_VTABLE_START(0), | |
556089dc LP |
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("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), SD_BUS_VTABLE_PROPERTY_CONST), | |
16 | SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), SD_BUS_VTABLE_PROPERTY_CONST), | |
718db961 | 17 | SD_BUS_VTABLE_END |
4819ff03 | 18 | }; |
a6c0353b | 19 | |
88629599 YW |
20 | static BUS_DEFINE_SET_TRANSIENT_PARSE(kill_mode, KillMode, kill_mode_from_string); |
21 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING(kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check); | |
22 | ||
a6c0353b LP |
23 | int bus_kill_context_set_transient_property( |
24 | Unit *u, | |
25 | KillContext *c, | |
26 | const char *name, | |
718db961 | 27 | sd_bus_message *message, |
2e59b241 | 28 | UnitWriteFlags flags, |
718db961 LP |
29 | sd_bus_error *error) { |
30 | ||
a6c0353b LP |
31 | assert(u); |
32 | assert(c); | |
33 | assert(name); | |
718db961 | 34 | assert(message); |
a6c0353b | 35 | |
2e59b241 LP |
36 | flags |= UNIT_PRIVATE; |
37 | ||
88629599 YW |
38 | if (streq(name, "KillMode")) |
39 | return bus_set_transient_kill_mode(u, name, &c->kill_mode, message, flags, error); | |
c3df8d3d | 40 | |
88629599 YW |
41 | if (streq(name, "SendSIGHUP")) |
42 | return bus_set_transient_bool(u, name, &c->send_sighup, message, flags, error); | |
a6c0353b | 43 | |
88629599 YW |
44 | if (streq(name, "SendSIGKILL")) |
45 | return bus_set_transient_bool(u, name, &c->send_sigkill, message, flags, error); | |
a6c0353b | 46 | |
88629599 YW |
47 | if (streq(name, "KillSignal")) |
48 | return bus_set_transient_kill_signal(u, name, &c->kill_signal, message, flags, error); | |
a6c0353b LP |
49 | |
50 | return 0; | |
51 | } |