]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
4819ff03 | 2 | |
40af3d02 | 3 | #include "bus-get-properties.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 | |
a232ebcc ZJS |
11 | static int property_get_restart_kill_signal( |
12 | sd_bus *bus, | |
13 | const char *path, | |
14 | const char *interface, | |
15 | const char *property, | |
16 | sd_bus_message *reply, | |
17 | void *userdata, | |
18 | sd_bus_error *error) { | |
19 | KillContext *c = userdata; | |
20 | int s; | |
21 | ||
22 | assert(c); | |
23 | ||
24 | s = restart_kill_signal(c); | |
25 | return sd_bus_message_append_basic(reply, 'i', &s); | |
26 | } | |
27 | ||
718db961 LP |
28 | const sd_bus_vtable bus_kill_vtable[] = { |
29 | SD_BUS_VTABLE_START(0), | |
556089dc LP |
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), | |
a232ebcc | 32 | SD_BUS_PROPERTY("RestartKillSignal", "i", property_get_restart_kill_signal, 0, SD_BUS_VTABLE_PROPERTY_CONST), |
fbb48d4c | 33 | SD_BUS_PROPERTY("FinalKillSignal", "i", bus_property_get_int, offsetof(KillContext, final_kill_signal), SD_BUS_VTABLE_PROPERTY_CONST), |
556089dc LP |
34 | SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), SD_BUS_VTABLE_PROPERTY_CONST), |
35 | SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), SD_BUS_VTABLE_PROPERTY_CONST), | |
c87700a1 | 36 | SD_BUS_PROPERTY("WatchdogSignal", "i", bus_property_get_int, offsetof(KillContext, watchdog_signal), SD_BUS_VTABLE_PROPERTY_CONST), |
718db961 | 37 | SD_BUS_VTABLE_END |
4819ff03 | 38 | }; |
a6c0353b | 39 | |
88629599 YW |
40 | static BUS_DEFINE_SET_TRANSIENT_PARSE(kill_mode, KillMode, kill_mode_from_string); |
41 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING(kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check); | |
a232ebcc | 42 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING(restart_kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check); |
fbb48d4c | 43 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING(final_kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check); |
c87700a1 | 44 | static BUS_DEFINE_SET_TRANSIENT_TO_STRING(watchdog_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check); |
88629599 | 45 | |
a6c0353b LP |
46 | int bus_kill_context_set_transient_property( |
47 | Unit *u, | |
48 | KillContext *c, | |
49 | const char *name, | |
718db961 | 50 | sd_bus_message *message, |
2e59b241 | 51 | UnitWriteFlags flags, |
718db961 LP |
52 | sd_bus_error *error) { |
53 | ||
a6c0353b LP |
54 | assert(u); |
55 | assert(c); | |
56 | assert(name); | |
718db961 | 57 | assert(message); |
a6c0353b | 58 | |
2e59b241 LP |
59 | flags |= UNIT_PRIVATE; |
60 | ||
88629599 YW |
61 | if (streq(name, "KillMode")) |
62 | return bus_set_transient_kill_mode(u, name, &c->kill_mode, message, flags, error); | |
c3df8d3d | 63 | |
88629599 YW |
64 | if (streq(name, "SendSIGHUP")) |
65 | return bus_set_transient_bool(u, name, &c->send_sighup, message, flags, error); | |
a6c0353b | 66 | |
88629599 YW |
67 | if (streq(name, "SendSIGKILL")) |
68 | return bus_set_transient_bool(u, name, &c->send_sigkill, message, flags, error); | |
a6c0353b | 69 | |
88629599 YW |
70 | if (streq(name, "KillSignal")) |
71 | return bus_set_transient_kill_signal(u, name, &c->kill_signal, message, flags, error); | |
a6c0353b | 72 | |
a232ebcc ZJS |
73 | if (streq(name, "RestartKillSignal")) |
74 | return bus_set_transient_restart_kill_signal(u, name, &c->restart_kill_signal, message, flags, error); | |
75 | ||
fbb48d4c JR |
76 | if (streq(name, "FinalKillSignal")) |
77 | return bus_set_transient_final_kill_signal(u, name, &c->final_kill_signal, message, flags, error); | |
78 | ||
c87700a1 AZ |
79 | if (streq(name, "WatchdogSignal")) |
80 | return bus_set_transient_watchdog_signal(u, name, &c->watchdog_signal, message, flags, error); | |
81 | ||
a6c0353b LP |
82 | return 0; |
83 | } |