summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-execute.c4
-rw-r--r--src/core/dbus-execute.h1
-rw-r--r--src/core/dbus-kill.c35
-rw-r--r--src/core/dbus-kill.h39
-rw-r--r--src/core/dbus-mount.c3
-rw-r--r--src/core/dbus-service.c4
-rw-r--r--src/core/dbus-socket.c3
-rw-r--r--src/core/dbus-swap.c3
-rw-r--r--src/core/execute.c34
-rw-r--r--src/core/execute.h27
-rw-r--r--src/core/kill.c63
-rw-r--r--src/core/kill.h58
-rw-r--r--src/core/load-fragment-gperf.gperf.m412
-rw-r--r--src/core/mount.c17
-rw-r--r--src/core/mount.h2
-rw-r--r--src/core/service.c19
-rw-r--r--src/core/service.h3
-rw-r--r--src/core/socket.c14
-rw-r--r--src/core/socket.h1
-rw-r--r--src/core/swap.c14
-rw-r--r--src/core/swap.h1
21 files changed, 265 insertions, 92 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index a00ad50795..e815cb58e4 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -30,8 +30,6 @@
#include "dbus-common.h"
#include "syscall-list.h"
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_kill_mode, kill_mode, KillMode);
-
DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_input, exec_input, ExecInput);
DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_output, exec_output, ExecOutput);
@@ -431,8 +429,6 @@ const BusProperty bus_exec_context_properties[] = {
{ "PrivateTmp", bus_property_append_bool, "b", offsetof(ExecContext, private_tmp) },
{ "PrivateNetwork", bus_property_append_bool, "b", offsetof(ExecContext, private_network) },
{ "SameProcessGroup", bus_property_append_bool, "b", offsetof(ExecContext, same_pgrp) },
- { "KillMode", bus_execute_append_kill_mode, "s", offsetof(ExecContext, kill_mode) },
- { "KillSignal", bus_property_append_int, "i", offsetof(ExecContext, kill_signal) },
{ "UtmpIdentifier", bus_property_append_string, "s", offsetof(ExecContext, utmp_id), true },
{ "ControlGroupModify", bus_property_append_bool, "b", offsetof(ExecContext, control_group_modify) },
{ "ControlGroupPersistent", bus_property_append_tristate_false, "b", offsetof(ExecContext, control_group_persistent) },
diff --git a/src/core/dbus-execute.h b/src/core/dbus-execute.h
index feb883335f..eaa1b73e69 100644
--- a/src/core/dbus-execute.h
+++ b/src/core/dbus-execute.h
@@ -120,6 +120,5 @@ int bus_execute_append_capabilities(DBusMessageIter *i, const char *property, vo
int bus_execute_append_capability_bs(DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_rlimits(DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_command(DBusMessageIter *u, const char *property, void *data);
-int bus_execute_append_kill_mode(DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_env_files(DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_syscall_filter(DBusMessageIter *i, const char *property, void *data);
diff --git a/src/core/dbus-kill.c b/src/core/dbus-kill.c
new file mode 100644
index 0000000000..165f63074b
--- /dev/null
+++ b/src/core/dbus-kill.c
@@ -0,0 +1,35 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2012 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <dbus/dbus.h>
+
+#include "dbus-kill.h"
+#include "dbus-common.h"
+
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_kill_append_mode, kill_mode, KillMode);
+
+const BusProperty bus_kill_context_properties[] = {
+ { "KillMode", bus_kill_append_mode, "s", offsetof(KillContext, kill_mode) },
+ { "KillSignal", bus_property_append_int, "i", offsetof(KillContext, kill_signal) },
+ { "SendSIGKILL", bus_property_append_bool, "b", offsetof(KillContext, send_sigkill) },
+ { NULL, }
+};
diff --git a/src/core/dbus-kill.h b/src/core/dbus-kill.h
new file mode 100644
index 0000000000..238fbd36d6
--- /dev/null
+++ b/src/core/dbus-kill.h
@@ -0,0 +1,39 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2012 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "manager.h"
+#include "dbus-common.h"
+
+#define BUS_KILL_CONTEXT_INTERFACE \
+ " <property name=\"KillMode\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"KillSignal\" type=\"i\" access=\"read\"/>\n" \
+ " <property name=\"SendSIGKILL\" type=\"b\" access=\"read\"/>\n"
+
+#define BUS_KILL_COMMAND_INTERFACE(name) \
+ " <property name=\"" name "\" type=\"a(sasbttuii)\" access=\"read\"/>\n"
+
+extern const BusProperty bus_kill_context_properties[];
+
+int bus_kill_append_mode(DBusMessageIter *i, const char *property, void *data);
diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c
index 26b04abe5d..93bfa4c35d 100644
--- a/src/core/dbus-mount.c
+++ b/src/core/dbus-mount.c
@@ -23,6 +23,7 @@
#include "dbus-unit.h"
#include "dbus-mount.h"
+#include "dbus-kill.h"
#include "dbus-execute.h"
#include "dbus-common.h"
@@ -37,6 +38,7 @@
BUS_EXEC_COMMAND_INTERFACE("ExecUnmount") \
BUS_EXEC_COMMAND_INTERFACE("ExecRemount") \
BUS_EXEC_CONTEXT_INTERFACE \
+ BUS_KILL_CONTEXT_INTERFACE \
" <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Result\" type=\"s\" access=\"read\"/>\n" \
@@ -155,6 +157,7 @@ DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMess
{ "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
{ "org.freedesktop.systemd1.Mount", bus_mount_properties, m },
{ "org.freedesktop.systemd1.Mount", bus_exec_context_properties, &m->exec_context },
+ { "org.freedesktop.systemd1.Mount", bus_kill_context_properties, &m->kill_context },
{ NULL, }
};
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index 6568cd5ce0..c0fac16d2b 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -23,6 +23,7 @@
#include "dbus-unit.h"
#include "dbus-execute.h"
+#include "dbus-kill.h"
#include "dbus-service.h"
#include "dbus-common.h"
@@ -47,6 +48,7 @@
BUS_EXEC_COMMAND_INTERFACE("ExecStop") \
BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
BUS_EXEC_CONTEXT_INTERFACE \
+ BUS_KILL_CONTEXT_INTERFACE \
" <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"RemainAfterExit\" type=\"b\" access=\"read\"/>\n" \
@@ -140,10 +142,12 @@ static const BusProperty bus_service_properties[] = {
DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
Service *s = SERVICE(u);
+
const BusBoundProperties bps[] = {
{ "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
{ "org.freedesktop.systemd1.Service", bus_service_properties, s },
{ "org.freedesktop.systemd1.Service", bus_exec_context_properties, &s->exec_context },
+ { "org.freedesktop.systemd1.Service", bus_kill_context_properties, &s->kill_context },
{ "org.freedesktop.systemd1.Service", bus_exec_main_status_properties, &s->main_exec_status },
{ NULL, }
};
diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index 80d19dd1bd..b2045225d7 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -24,6 +24,7 @@
#include "dbus-unit.h"
#include "dbus-socket.h"
#include "dbus-execute.h"
+#include "dbus-kill.h"
#include "dbus-common.h"
#define BUS_SOCKET_INTERFACE \
@@ -36,6 +37,7 @@
BUS_EXEC_COMMAND_INTERFACE("ExecStopPre") \
BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
BUS_EXEC_CONTEXT_INTERFACE \
+ BUS_KILL_CONTEXT_INTERFACE \
" <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"BindToDevice\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
@@ -132,6 +134,7 @@ DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMes
{ "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
{ "org.freedesktop.systemd1.Socket", bus_socket_properties, s },
{ "org.freedesktop.systemd1.Socket", bus_exec_context_properties, &s->exec_context },
+ { "org.freedesktop.systemd1.Socket", bus_kill_context_properties, &s->kill_context },
{ NULL, }
};
diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c
index 3ede0e606e..cad6ec1aaa 100644
--- a/src/core/dbus-swap.c
+++ b/src/core/dbus-swap.c
@@ -25,6 +25,7 @@
#include "dbus-unit.h"
#include "dbus-swap.h"
#include "dbus-execute.h"
+#include "dbus-kill.h"
#include "dbus-common.h"
#define BUS_SWAP_INTERFACE \
@@ -35,6 +36,7 @@
BUS_EXEC_COMMAND_INTERFACE("ExecActivate") \
BUS_EXEC_COMMAND_INTERFACE("ExecDeactivate") \
BUS_EXEC_CONTEXT_INTERFACE \
+ BUS_KILL_CONTEXT_INTERFACE \
" <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Result\" type=\"s\" access=\"read\"/>\n" \
" </interface>\n"
@@ -102,6 +104,7 @@ DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessa
{ "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
{ "org.freedesktop.systemd1.Swap", bus_swap_properties, s },
{ "org.freedesktop.systemd1.Swap", bus_exec_context_properties, &s->exec_context },
+ { "org.freedesktop.systemd1.Swap", bus_kill_context_properties, &s->kill_context },
{ NULL, }
};
diff --git a/src/core/execute.c b/src/core/execute.c
index db4a8ae51c..fc0edc6cfd 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1541,8 +1541,6 @@ void exec_context_init(ExecContext *c) {
c->syslog_priority = LOG_DAEMON|LOG_INFO;
c->syslog_level_prefix = true;
c->mount_flags = MS_SHARED;
- c->kill_signal = SIGTERM;
- c->send_sigkill = true;
c->control_group_persistent = -1;
c->ignore_sigpipe = true;
c->timer_slack_nsec = (nsec_t) -1;
@@ -1735,7 +1733,8 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
"%sPrivateTmp: %s\n"
"%sControlGroupModify: %s\n"
"%sControlGroupPersistent: %s\n"
- "%sPrivateNetwork: %s\n",
+ "%sPrivateNetwork: %s\n"
+ "%sIgnoreSIGPIPE: %s\n",
prefix, c->umask,
prefix, c->working_directory ? c->working_directory : "/",
prefix, c->root_directory ? c->root_directory : "/",
@@ -1743,7 +1742,8 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
prefix, yes_no(c->private_tmp),
prefix, yes_no(c->control_group_modify),
prefix, yes_no(c->control_group_persistent),
- prefix, yes_no(c->private_network));
+ prefix, yes_no(c->private_network),
+ prefix, yes_no(c->ignore_sigpipe));
STRV_FOREACH(e, c->environment)
fprintf(f, "%sEnvironment: %s\n", prefix, *e);
@@ -1894,16 +1894,6 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
fputs("\n", f);
}
- fprintf(f,
- "%sKillMode: %s\n"
- "%sKillSignal: SIG%s\n"
- "%sSendSIGKILL: %s\n"
- "%sIgnoreSIGPIPE: %s\n",
- prefix, kill_mode_to_string(c->kill_mode),
- prefix, signal_to_string(c->kill_signal),
- prefix, yes_no(c->send_sigkill),
- prefix, yes_no(c->ignore_sigpipe));
-
if (c->utmp_id)
fprintf(f,
"%sUtmpIdentifier: %s\n",
@@ -2111,19 +2101,3 @@ static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = {
};
DEFINE_STRING_TABLE_LOOKUP(exec_output, ExecOutput);
-
-static const char* const kill_mode_table[_KILL_MODE_MAX] = {
- [KILL_CONTROL_GROUP] = "control-group",
- [KILL_PROCESS] = "process",
- [KILL_NONE] = "none"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(kill_mode, KillMode);
-
-static const char* const kill_who_table[_KILL_WHO_MAX] = {
- [KILL_MAIN] = "main",
- [KILL_CONTROL] = "control",
- [KILL_ALL] = "all"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(kill_who, KillWho);
diff --git a/src/core/execute.h b/src/core/execute.h
index 09f246e161..2bcd2e1e6c 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -39,22 +39,6 @@ struct CGroupAttribute;
#include "list.h"
#include "util.h"
-typedef enum KillMode {
- KILL_CONTROL_GROUP = 0,
- KILL_PROCESS,
- KILL_NONE,
- _KILL_MODE_MAX,
- _KILL_MODE_INVALID = -1
-} KillMode;
-
-typedef enum KillWho {
- KILL_MAIN,
- KILL_CONTROL,
- KILL_ALL,
- _KILL_WHO_MAX,
- _KILL_WHO_INVALID = -1
-} KillWho;
-
typedef enum ExecInput {
EXEC_INPUT_NULL,
EXEC_INPUT_TTY,
@@ -146,11 +130,6 @@ struct ExecContext {
uint64_t capability_bounding_set_drop;
- /* Not relevant for spawning processes, just for killing */
- KillMode kill_mode;
- int kill_signal;
- bool send_sigkill;
-
cap_t capabilities;
int secure_bits;
@@ -228,9 +207,3 @@ ExecOutput exec_output_from_string(const char *s);
const char* exec_input_to_string(ExecInput i);
ExecInput exec_input_from_string(const char *s);
-
-const char *kill_mode_to_string(KillMode k);
-KillMode kill_mode_from_string(const char *s);
-
-const char *kill_who_to_string(KillWho k);
-KillWho kill_who_from_string(const char *s);
diff --git a/src/core/kill.c b/src/core/kill.c
new file mode 100644
index 0000000000..0775653f73
--- /dev/null
+++ b/src/core/kill.c
@@ -0,0 +1,63 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2012 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <string.h>
+
+#include "kill.h"
+#include "util.h"
+
+void kill_context_init(KillContext *c) {
+ assert(c);
+
+ c->kill_signal = SIGTERM;
+ c->send_sigkill = true;
+}
+
+void kill_context_dump(KillContext *c, FILE *f, const char *prefix) {
+ assert(c);
+
+ if (!prefix)
+ prefix = "";
+
+ fprintf(f,
+ "%sKillMode: %s\n"
+ "%sKillSignal: SIG%s\n"
+ "%sSendSIGKILL: %s\n",
+ prefix, kill_mode_to_string(c->kill_mode),
+ prefix, signal_to_string(c->kill_signal),
+ prefix, yes_no(c->send_sigkill));
+}
+
+static const char* const kill_mode_table[_KILL_MODE_MAX] = {
+ [KILL_CONTROL_GROUP] = "control-group",
+ [KILL_PROCESS] = "process",
+ [KILL_NONE] = "none"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(kill_mode, KillMode);
+
+static const char* const kill_who_table[_KILL_WHO_MAX] = {
+ [KILL_MAIN] = "main",
+ [KILL_CONTROL] = "control",
+ [KILL_ALL] = "all"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(kill_who, KillWho);
diff --git a/src/core/kill.h b/src/core/kill.h
new file mode 100644
index 0000000000..4f88239271
--- /dev/null
+++ b/src/core/kill.h
@@ -0,0 +1,58 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2012 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+typedef struct KillContext KillContext;
+
+#include <stdbool.h>
+#include <stdio.h>
+
+typedef enum KillMode {
+ KILL_CONTROL_GROUP = 0,
+ KILL_PROCESS,
+ KILL_NONE,
+ _KILL_MODE_MAX,
+ _KILL_MODE_INVALID = -1
+} KillMode;
+
+struct KillContext {
+ KillMode kill_mode;
+ int kill_signal;
+ bool send_sigkill;
+};
+
+typedef enum KillWho {
+ KILL_MAIN,
+ KILL_CONTROL,
+ KILL_ALL,
+ _KILL_WHO_MAX,
+ _KILL_WHO_INVALID = -1
+} KillWho;
+
+void kill_context_init(KillContext *c);
+void kill_context_dump(KillContext *c, FILE *f, const char *prefix);
+
+const char *kill_mode_to_string(KillMode k);
+KillMode kill_mode_from_string(const char *s);
+
+const char *kill_who_to_string(KillWho k);
+KillWho kill_who_from_string(const char *s);
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 140cb9c0a3..d6a4711a32 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -84,14 +84,16 @@ $1.PrivateNetwork, config_parse_bool, 0,
$1.MountFlags, config_parse_exec_mount_flags, 0, offsetof($1, exec_context)
$1.TCPWrapName, config_parse_unit_string_printf, 0, offsetof($1, exec_context.tcpwrap_name)
$1.PAMName, config_parse_unit_string_printf, 0, offsetof($1, exec_context.pam_name)
-$1.KillMode, config_parse_kill_mode, 0, offsetof($1, exec_context.kill_mode)
-$1.KillSignal, config_parse_kill_signal, 0, offsetof($1, exec_context.kill_signal)
-$1.SendSIGKILL, config_parse_bool, 0, offsetof($1, exec_context.send_sigkill)
$1.IgnoreSIGPIPE, config_parse_bool, 0, offsetof($1, exec_context.ignore_sigpipe)
$1.UtmpIdentifier, config_parse_unit_string_printf, 0, offsetof($1, exec_context.utmp_id)
$1.ControlGroupModify, config_parse_bool, 0, offsetof($1, exec_context.control_group_modify)
$1.ControlGroupPersistent, config_parse_tristate, 0, offsetof($1, exec_context.control_group_persistent)'
)m4_dnl
+m4_define(`KILL_CONTEXT_CONFIG_ITEMS',
+`$1.SendSIGKILL, config_parse_bool, 0, offsetof($1, kill_context.send_sigkill)
+$1.KillMode, config_parse_kill_mode, 0, offsetof($1, kill_context.kill_mode)
+$1.KillSignal, config_parse_kill_signal, 0, offsetof($1, kill_context.kill_signal)'
+)m4_dnl
Unit.Description, config_parse_unit_string_printf, 0, offsetof(Unit, description)
Unit.Documentation, config_parse_documentation, 0, offsetof(Unit, documentation)
Unit.SourcePath, config_parse_path, 0, offsetof(Unit, source_path)
@@ -162,6 +164,7 @@ Service.NotifyAccess, config_parse_notify_access, 0,
Service.Sockets, config_parse_service_sockets, 0, 0
Service.FsckPassNo, config_parse_fsck_passno, 0, offsetof(Service, fsck_passno)
EXEC_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
+KILL_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
m4_dnl
Socket.ListenStream, config_parse_socket_listen, 0, 0
Socket.ListenDatagram, config_parse_socket_listen, 0, 0
@@ -200,6 +203,7 @@ Socket.MessageQueueMaxMessages, config_parse_long, 0,
Socket.MessageQueueMessageSize, config_parse_long, 0, offsetof(Socket, mq_msgsize)
Socket.Service, config_parse_socket_service, 0, 0
EXEC_CONTEXT_CONFIG_ITEMS(Socket)m4_dnl
+KILL_CONTEXT_CONFIG_ITEMS(Socket)m4_dnl
m4_dnl
Mount.What, config_parse_string, 0, offsetof(Mount, parameters_fragment.what)
Mount.Where, config_parse_path, 0, offsetof(Mount, where)
@@ -209,6 +213,7 @@ Mount.FsckPassNo, config_parse_fsck_passno, 0,
Mount.TimeoutSec, config_parse_usec, 0, offsetof(Mount, timeout_usec)
Mount.DirectoryMode, config_parse_mode, 0, offsetof(Mount, directory_mode)
EXEC_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
+KILL_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
m4_dnl
Automount.Where, config_parse_path, 0, offsetof(Automount, where)
Automount.DirectoryMode, config_parse_mode, 0, offsetof(Automount, directory_mode)
@@ -217,6 +222,7 @@ Swap.What, config_parse_path, 0,
Swap.Priority, config_parse_int, 0, offsetof(Swap, parameters_fragment.priority)
Swap.TimeoutSec, config_parse_usec, 0, offsetof(Swap, timeout_usec)
EXEC_CONTEXT_CONFIG_ITEMS(Swap)m4_dnl
+KILL_CONTEXT_CONFIG_ITEMS(Swap)m4_dnl
m4_dnl
Timer.OnActiveSec, config_parse_timer, 0, 0
Timer.OnBootSec, config_parse_timer, 0, 0
diff --git a/src/core/mount.c b/src/core/mount.c
index a88b255875..82c64ff79b 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -79,6 +79,8 @@ static void mount_init(Unit *u) {
m->exec_context.std_error = u->manager->default_std_error;
}
+ kill_context_init(&m->kill_context);
+
/* We need to make sure that /bin/mount is always called in
* the same process group as us, so that the autofs kernel
* side doesn't send us another mount request while we are
@@ -529,7 +531,7 @@ static int mount_verify(Mount *m) {
return -EBADMSG;
}
- if (m->exec_context.pam_name && m->exec_context.kill_mode != KILL_CONTROL_GROUP) {
+ if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) {
log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(m)->id);
return -EINVAL;
}
@@ -783,6 +785,7 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
prefix, (unsigned long) m->control_pid);
exec_context_dump(&m->exec_context, f, prefix);
+ kill_context_dump(&m->kill_context, f, prefix);
}
static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
@@ -855,10 +858,10 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
if (f != MOUNT_SUCCESS)
m->result = f;
- if (m->exec_context.kill_mode != KILL_NONE) {
+ if (m->kill_context.kill_mode != KILL_NONE) {
int sig = (state == MOUNT_MOUNTING_SIGTERM ||
state == MOUNT_UNMOUNTING_SIGTERM ||
- state == MOUNT_REMOUNTING_SIGTERM) ? m->exec_context.kill_signal : SIGKILL;
+ state == MOUNT_REMOUNTING_SIGTERM) ? m->kill_context.kill_signal : SIGKILL;
if (m->control_pid > 0) {
if (kill_and_sigcont(m->control_pid, sig) < 0 && errno != ESRCH)
@@ -868,7 +871,7 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
wait_for_exit = true;
}
- if (m->exec_context.kill_mode == KILL_CONTROL_GROUP) {
+ if (m->kill_context.kill_mode == KILL_CONTROL_GROUP) {
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func))) {
r = -ENOMEM;
@@ -1327,7 +1330,7 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case MOUNT_MOUNTING_SIGTERM:
- if (m->exec_context.send_sigkill) {
+ if (m->kill_context.send_sigkill) {
log_warning("%s mounting timed out. Killing.", u->id);
mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
} else {
@@ -1341,7 +1344,7 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case MOUNT_REMOUNTING_SIGTERM:
- if (m->exec_context.send_sigkill) {
+ if (m->kill_context.send_sigkill) {
log_warning("%s remounting timed out. Killing.", u->id);
mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
} else {
@@ -1355,7 +1358,7 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case MOUNT_UNMOUNTING_SIGTERM:
- if (m->exec_context.send_sigkill) {
+ if (m->kill_context.send_sigkill) {
log_warning("%s unmounting timed out. Killing.", u->id);
mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
} else {
diff --git a/src/core/mount.h b/src/core/mount.h
index 9583eebe3a..67d6132a5d 100644
--- a/src/core/mount.h
+++ b/src/core/mount.h
@@ -24,6 +24,7 @@
typedef struct Mount Mount;
#include "unit.h"
+#include "kill.h"
typedef enum MountState {
MOUNT_DEAD,
@@ -95,6 +96,7 @@ struct Mount {
ExecCommand exec_command[_MOUNT_EXEC_COMMAND_MAX];
ExecContext exec_context;
+ KillContext kill_context;
MountState state, deserialized_state;
diff --git a/src/core/service.c b/src/core/service.c
index 5dc06b36cc..567e9a4eb3 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -153,6 +153,7 @@ static void service_init(Unit *u) {
for (i = 0; i < RLIMIT_NLIMITS; i++)
if (UNIT(s)->manager->rlimit[i])
s->exec_context.rlimit[i] = newdup(struct rlimit, UNIT(s)->manager->rlimit[i], 1);
+ kill_context_init(&s->kill_context);
RATELIMIT_INIT(s->start_limit, 10*USEC_PER_SEC, 5);
@@ -928,7 +929,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
s->guess_main_pid = false;
s->restart = SERVICE_RESTART_NO;
s->exec_context.ignore_sigpipe = false;
- s->exec_context.kill_mode = KILL_PROCESS;
+ s->kill_context.kill_mode = KILL_PROCESS;
/* We use the long description only if
* no short description is set. */
@@ -1164,7 +1165,7 @@ static int service_verify(Service *s) {
if (s->bus_name && s->type != SERVICE_DBUS)
log_warning("%s has a D-Bus service name specified, but is not of type dbus. Ignoring.", UNIT(s)->id);
- if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
+ if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -1351,6 +1352,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
prefix, s->bus_name,
prefix, yes_no(s->bus_name_good));
+ kill_context_dump(&s->kill_context, f, prefix);
exec_context_dump(&s->exec_context, f, prefix);
for (c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++) {
@@ -1967,8 +1969,8 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
if (f != SERVICE_SUCCESS)
s->result = f;
- if (s->exec_context.kill_mode != KILL_NONE) {
- int sig = (state == SERVICE_STOP_SIGTERM || state == SERVICE_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
+ if (s->kill_context.kill_mode != KILL_NONE) {
+ int sig = (state == SERVICE_STOP_SIGTERM || state == SERVICE_FINAL_SIGTERM) ? s->kill_context.kill_signal : SIGKILL;
if (s->main_pid > 0) {
if (kill_and_sigcont(s->main_pid, sig) < 0 && errno != ESRCH)
@@ -1984,9 +1986,10 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
wait_for_exit = true;
}
- if (s->exec_context.kill_mode == KILL_CONTROL_GROUP) {
+ if (s->kill_context.kill_mode == KILL_CONTROL_GROUP) {
- if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func))) {
+ pid_set = set_new(trivial_hash_func, trivial_compare_func);
+ if (!pid_set) {
r = -ENOMEM;
goto fail;
}
@@ -3144,7 +3147,7 @@ static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
break;
case SERVICE_STOP_SIGTERM:
- if (s->exec_context.send_sigkill) {
+ if (s->kill_context.send_sigkill) {
log_warning("%s stopping timed out. Killing.", u->id);
service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_FAILURE_TIMEOUT);
} else {
@@ -3169,7 +3172,7 @@ static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
break;
case SERVICE_FINAL_SIGTERM:
- if (s->exec_context.send_sigkill) {
+ if (s->kill_context.send_sigkill) {
log_warning("%s stopping timed out (2). Killing.", u->id);
service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_FAILURE_TIMEOUT);
} else {
diff --git a/src/core/service.h b/src/core/service.h
index 5ad09d0acc..cc63347c76 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -27,6 +27,7 @@ typedef struct Service Service;
#include "path.h"
#include "ratelimit.h"
#include "service.h"
+#include "kill.h"
typedef enum ServiceState {
SERVICE_DEAD,
@@ -126,7 +127,9 @@ struct Service {
Watch watchdog_watch;
ExecCommand* exec_command[_SERVICE_EXEC_COMMAND_MAX];
+
ExecContext exec_context;
+ KillContext kill_context;
ServiceState state, deserialized_state;
diff --git a/src/core/socket.c b/src/core/socket.c
index 8153a8e762..6d417878b5 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -83,6 +83,7 @@ static void socket_init(Unit *u) {
exec_context_init(&s->exec_context);
s->exec_context.std_output = u->manager->default_std_output;
s->exec_context.std_error = u->manager->default_std_error;
+ kill_context_init(&s->kill_context);
s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
}
@@ -223,7 +224,7 @@ static int socket_verify(Socket *s) {
return -EINVAL;
}
- if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
+ if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -526,6 +527,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
}
exec_context_dump(&s->exec_context, f, prefix);
+ kill_context_dump(&s->kill_context, f, prefix);
for (c = 0; c < _SOCKET_EXEC_COMMAND_MAX; c++) {
if (!s->exec_command[c])
@@ -1226,8 +1228,8 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
if (f != SOCKET_SUCCESS)
s->result = f;
- if (s->exec_context.kill_mode != KILL_NONE) {
- int sig = (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
+ if (s->kill_context.kill_mode != KILL_NONE) {
+ int sig = (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_FINAL_SIGTERM) ? s->kill_context.kill_signal : SIGKILL;
if (s->control_pid > 0) {
if (kill_and_sigcont(s->control_pid, sig) < 0 && errno != ESRCH)
@@ -1237,7 +1239,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
wait_for_exit = true;
}
- if (s->exec_context.kill_mode == KILL_CONTROL_GROUP) {
+ if (s->kill_context.kill_mode == KILL_CONTROL_GROUP) {
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func))) {
r = -ENOMEM;
@@ -1983,7 +1985,7 @@ static void socket_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case SOCKET_STOP_PRE_SIGTERM:
- if (s->exec_context.send_sigkill) {
+ if (s->kill_context.send_sigkill) {
log_warning("%s stopping timed out. Killing.", u->id);
socket_enter_signal(s, SOCKET_STOP_PRE_SIGKILL, SOCKET_FAILURE_TIMEOUT);
} else {
@@ -2003,7 +2005,7 @@ static void socket_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case SOCKET_FINAL_SIGTERM:
- if (s->exec_context.send_sigkill) {
+ if (s->kill_context.send_sigkill) {
log_warning("%s stopping timed out (2). Killing.", u->id);
socket_enter_signal(s, SOCKET_FINAL_SIGKILL, SOCKET_FAILURE_TIMEOUT);
} else {
diff --git a/src/core/socket.h b/src/core/socket.h
index 508f00eb34..a06b3eae94 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -101,6 +101,7 @@ struct Socket {
ExecCommand* exec_command[_SOCKET_EXEC_COMMAND_MAX];
ExecContext exec_context;
+ KillContext kill_context;
/* For Accept=no sockets refers to the one service we'll
activate. For Accept=yes sockets is either NULL, or filled
diff --git a/src/core/swap.c b/src/core/swap.c
index ed61ba3c81..03993b1e60 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -86,6 +86,7 @@ static void swap_init(Unit *u) {
exec_context_init(&s->exec_context);
s->exec_context.std_output = u->manager->default_std_output;
s->exec_context.std_error = u->manager->default_std_error;
+ kill_context_init(&s->kill_context);
s->parameters_proc_swaps.priority = s->parameters_fragment.priority = -1;
@@ -235,7 +236,7 @@ static int swap_verify(Swap *s) {
return -EINVAL;
}
- if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
+ if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -569,6 +570,7 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
prefix, (unsigned long) s->control_pid);
exec_context_dump(&s->exec_context, f, prefix);
+ kill_context_dump(&s->kill_context, f, prefix);
}
static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
@@ -641,9 +643,9 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
if (f != SWAP_SUCCESS)
s->result = f;
- if (s->exec_context.kill_mode != KILL_NONE) {
+ if (s->kill_context.kill_mode != KILL_NONE) {
int sig = (state == SWAP_ACTIVATING_SIGTERM ||
- state == SWAP_DEACTIVATING_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
+ state == SWAP_DEACTIVATING_SIGTERM) ? s->kill_context.kill_signal : SIGKILL;
if (s->control_pid > 0) {
if (kill_and_sigcont(s->control_pid, sig) < 0 && errno != ESRCH)
@@ -653,7 +655,7 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
wait_for_exit = true;
}
- if (s->exec_context.kill_mode == KILL_CONTROL_GROUP) {
+ if (s->kill_context.kill_mode == KILL_CONTROL_GROUP) {
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func))) {
r = -ENOMEM;
@@ -993,7 +995,7 @@ static void swap_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case SWAP_ACTIVATING_SIGTERM:
- if (s->exec_context.send_sigkill) {
+ if (s->kill_context.send_sigkill) {
log_warning("%s activation timed out. Killing.", u->id);
swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT);
} else {
@@ -1003,7 +1005,7 @@ static void swap_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
break;
case SWAP_DEACTIVATING_SIGTERM:
- if (s->exec_context.send_sigkill) {
+ if (s->kill_context.send_sigkill) {
log_warning("%s deactivation timed out. Killing.", u->id);
swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT);
} else {
diff --git a/src/core/swap.h b/src/core/swap.h
index d8888e1768..35d47fd46f 100644
--- a/src/core/swap.h
+++ b/src/core/swap.h
@@ -87,6 +87,7 @@ struct Swap {
ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX];
ExecContext exec_context;
+ KillContext kill_context;
SwapState state, deserialized_state;