dbus-kill.c revision c3df8d3dde5a032b382b3f59c016c1d0b7741ae8
97a9a944b5887e91042b019776c41d5dd74557aferikabele/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele/***
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is part of systemd.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive Copyright 2012 Lennart Poettering
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end systemd is free software; you can redistribute it and/or modify it
5a58787efeb02a1c3f06569d019ad81fd2efa06end under the terms of the GNU Lesser General Public License as published by
5a58787efeb02a1c3f06569d019ad81fd2efa06end the Free Software Foundation; either version 2.1 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen systemd is distributed in the hope that it will be useful, but
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen WITHOUT ANY WARRANTY; without even the implied warranty of
5a58787efeb02a1c3f06569d019ad81fd2efa06end MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5a58787efeb02a1c3f06569d019ad81fd2efa06end Lesser General Public License for more details.
5a58787efeb02a1c3f06569d019ad81fd2efa06end
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen You should have received a copy of the GNU Lesser General Public License
3f08db06526d6901aa08c110b5bc7dde6bc39905nd along with systemd; If not, see <http://www.gnu.org/licenses/>.
5a58787efeb02a1c3f06569d019ad81fd2efa06end***/
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end#include <errno.h>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#include <dbus/dbus.h>
5a58787efeb02a1c3f06569d019ad81fd2efa06end
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#include "dbus-kill.h"
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd#include "dbus-common.h"
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7ndstatic DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_kill_append_mode, kill_mode, KillMode);
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjungconst BusProperty bus_kill_context_properties[] = {
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd { "KillMode", bus_kill_append_mode, "s", offsetof(KillContext, kill_mode) },
5a58787efeb02a1c3f06569d019ad81fd2efa06end { "KillSignal", bus_property_append_int, "i", offsetof(KillContext, kill_signal) },
5a58787efeb02a1c3f06569d019ad81fd2efa06end { "SendSIGKILL", bus_property_append_bool, "b", offsetof(KillContext, send_sigkill) },
5a58787efeb02a1c3f06569d019ad81fd2efa06end { "SendSIGHUP", bus_property_append_bool, "b", offsetof(KillContext, send_sighup) },
5a58787efeb02a1c3f06569d019ad81fd2efa06end {}
5a58787efeb02a1c3f06569d019ad81fd2efa06end};
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06endint bus_kill_context_set_transient_property(
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Unit *u,
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd KillContext *c,
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive const char *name,
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd DBusMessageIter *i,
b21197dc8e6b8c764fdcc24d4bae8b0eebb6bc4end UnitSetPropertiesMode mode,
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive DBusError *error) {
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive assert(u);
97a9a944b5887e91042b019776c41d5dd74557aferikabele assert(c);
f8396ed8364b56ec8adeaa49cac35a929758a29eslive assert(name);
ffb01336be79c64046b636e59fa8ddca8ec029edsf assert(i);
f8396ed8364b56ec8adeaa49cac35a929758a29eslive
f8396ed8364b56ec8adeaa49cac35a929758a29eslive if (streq(name, "SendSIGHUP")) {
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN)
5a58787efeb02a1c3f06569d019ad81fd2efa06end return -EINVAL;
5a58787efeb02a1c3f06569d019ad81fd2efa06end
deeee6bb6fd94c0ba5f3730b58abd9d299c89ccdnd if (mode != UNIT_CHECK) {
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl dbus_bool_t b;
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cnd dbus_message_iter_get_basic(i, &b);
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf c->send_sighup = b;
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
ffb01336be79c64046b636e59fa8ddca8ec029edsf unit_write_drop_in_format(u, mode, name, "[Scope]\nSendSIGHUP=%s\n", yes_no(b));
117c1f888a14e73cdd821dc6c23eb0411144a41cnd }
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cnd return 1;
2bc7f1cf720973a67f8ff7a8d523e40569ae5b6cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cnd } else if (streq(name, "SendSIGKILL")) {
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cnd if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN)
117c1f888a14e73cdd821dc6c23eb0411144a41cnd return -EINVAL;
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cnd if (mode != UNIT_CHECK) {
87ffb6e33f3cbef3b9bb406cc2d27039fa336eaatrawick dbus_bool_t b;
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl
5a58787efeb02a1c3f06569d019ad81fd2efa06end dbus_message_iter_get_basic(i, &b);
5a58787efeb02a1c3f06569d019ad81fd2efa06end c->send_sigkill = b;
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end unit_write_drop_in_format(u, mode, name, "[Scope]\nSendSIGKILL4=%s\n", yes_no(b));
5a58787efeb02a1c3f06569d019ad81fd2efa06end }
5a58787efeb02a1c3f06569d019ad81fd2efa06end
654d8eb036bedc99e90e11910ee02d3421417697rbowen return 1;
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh
5a58787efeb02a1c3f06569d019ad81fd2efa06end }
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end return 0;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf}
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick