LCOV - code coverage report
Current view: top level - core - dbus-kill.c (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 0 44 0.0 %
Date: 2015-07-29 18:47:03 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
       2             : 
       3             : /***
       4             :   This file is part of systemd.
       5             : 
       6             :   Copyright 2012 Lennart Poettering
       7             : 
       8             :   systemd is free software; you can redistribute it and/or modify it
       9             :   under the terms of the GNU Lesser General Public License as published by
      10             :   the Free Software Foundation; either version 2.1 of the License, or
      11             :   (at your option) any later version.
      12             : 
      13             :   systemd is distributed in the hope that it will be useful, but
      14             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      16             :   Lesser General Public License for more details.
      17             : 
      18             :   You should have received a copy of the GNU Lesser General Public License
      19             :   along with systemd; If not, see <http://www.gnu.org/licenses/>.
      20             : ***/
      21             : 
      22             : #include "signal-util.h"
      23             : #include "bus-util.h"
      24             : 
      25             : #include "kill.h"
      26             : #include "dbus-kill.h"
      27             : 
      28           0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode);
      29             : 
      30             : const sd_bus_vtable bus_kill_vtable[] = {
      31             :         SD_BUS_VTABLE_START(0),
      32             :         SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), SD_BUS_VTABLE_PROPERTY_CONST),
      33             :         SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), SD_BUS_VTABLE_PROPERTY_CONST),
      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),
      36             :         SD_BUS_VTABLE_END
      37             : };
      38             : 
      39           0 : int bus_kill_context_set_transient_property(
      40             :                 Unit *u,
      41             :                 KillContext *c,
      42             :                 const char *name,
      43             :                 sd_bus_message *message,
      44             :                 UnitSetPropertiesMode mode,
      45             :                 sd_bus_error *error) {
      46             : 
      47             :         int r;
      48             : 
      49           0 :         assert(u);
      50           0 :         assert(c);
      51           0 :         assert(name);
      52           0 :         assert(message);
      53             : 
      54           0 :         if (streq(name, "KillMode")) {
      55             :                 const char *m;
      56             :                 KillMode k;
      57             : 
      58           0 :                 r = sd_bus_message_read(message, "s", &m);
      59           0 :                 if (r < 0)
      60           0 :                         return r;
      61             : 
      62           0 :                 k = kill_mode_from_string(m);
      63           0 :                 if (k < 0)
      64           0 :                         return -EINVAL;
      65             : 
      66           0 :                 if (mode != UNIT_CHECK) {
      67           0 :                         c->kill_mode = k;
      68             : 
      69           0 :                         unit_write_drop_in_private_format(u, mode, name, "KillMode=%s\n", kill_mode_to_string(k));
      70             :                 }
      71             : 
      72           0 :                 return 1;
      73             : 
      74           0 :         } else if (streq(name, "KillSignal")) {
      75             :                 int sig;
      76             : 
      77           0 :                 r = sd_bus_message_read(message, "i", &sig);
      78           0 :                 if (r < 0)
      79           0 :                         return r;
      80             : 
      81           0 :                 if (sig <= 0 || sig >= _NSIG)
      82           0 :                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Signal %i out of range", sig);
      83             : 
      84           0 :                 if (mode != UNIT_CHECK) {
      85           0 :                         c->kill_signal = sig;
      86             : 
      87           0 :                         unit_write_drop_in_private_format(u, mode, name, "KillSignal=%s\n", signal_to_string(sig));
      88             :                 }
      89             : 
      90           0 :                 return 1;
      91             : 
      92           0 :         } else if (streq(name, "SendSIGHUP")) {
      93             :                 int b;
      94             : 
      95           0 :                 r = sd_bus_message_read(message, "b", &b);
      96           0 :                 if (r < 0)
      97           0 :                         return r;
      98             : 
      99           0 :                 if (mode != UNIT_CHECK) {
     100           0 :                         c->send_sighup = b;
     101             : 
     102           0 :                         unit_write_drop_in_private_format(u, mode, name, "SendSIGHUP=%s\n", yes_no(b));
     103             :                 }
     104             : 
     105           0 :                 return 1;
     106             : 
     107           0 :         } else if (streq(name, "SendSIGKILL")) {
     108             :                 int b;
     109             : 
     110           0 :                 r = sd_bus_message_read(message, "b", &b);
     111           0 :                 if (r < 0)
     112           0 :                         return r;
     113             : 
     114           0 :                 if (mode != UNIT_CHECK) {
     115           0 :                         c->send_sigkill = b;
     116             : 
     117           0 :                         unit_write_drop_in_private_format(u, mode, name, "SendSIGKILL=%s\n", yes_no(b));
     118             :                 }
     119             : 
     120           0 :                 return 1;
     121             : 
     122             :         }
     123             : 
     124           0 :         return 0;
     125             : }

Generated by: LCOV version 1.11