]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/dbus-kill.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / core / dbus-kill.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 This file is part of systemd.
4
5 Copyright 2012 Lennart Poettering
6 ***/
7
8 #include "bus-util.h"
9 #include "dbus-kill.h"
10 #include "dbus-util.h"
11 #include "kill.h"
12 #include "signal-util.h"
13
14 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode);
15
16 const sd_bus_vtable bus_kill_vtable[] = {
17 SD_BUS_VTABLE_START(0),
18 SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), SD_BUS_VTABLE_PROPERTY_CONST),
19 SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), SD_BUS_VTABLE_PROPERTY_CONST),
20 SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), SD_BUS_VTABLE_PROPERTY_CONST),
21 SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), SD_BUS_VTABLE_PROPERTY_CONST),
22 SD_BUS_VTABLE_END
23 };
24
25 static BUS_DEFINE_SET_TRANSIENT_PARSE(kill_mode, KillMode, kill_mode_from_string);
26 static BUS_DEFINE_SET_TRANSIENT_TO_STRING(kill_signal, "i", int32_t, int, "%" PRIi32, signal_to_string_with_check);
27
28 int bus_kill_context_set_transient_property(
29 Unit *u,
30 KillContext *c,
31 const char *name,
32 sd_bus_message *message,
33 UnitWriteFlags flags,
34 sd_bus_error *error) {
35
36 assert(u);
37 assert(c);
38 assert(name);
39 assert(message);
40
41 flags |= UNIT_PRIVATE;
42
43 if (streq(name, "KillMode"))
44 return bus_set_transient_kill_mode(u, name, &c->kill_mode, message, flags, error);
45
46 if (streq(name, "SendSIGHUP"))
47 return bus_set_transient_bool(u, name, &c->send_sighup, message, flags, error);
48
49 if (streq(name, "SendSIGKILL"))
50 return bus_set_transient_bool(u, name, &c->send_sigkill, message, flags, error);
51
52 if (streq(name, "KillSignal"))
53 return bus_set_transient_kill_signal(u, name, &c->kill_signal, message, flags, error);
54
55 return 0;
56 }