core: drop KillMode parameter from KillUnit() bus call
It made no sense, and since we are documenting the bus calls now and want to include them in our stability promise we really should get it cleaned up sooner, not later.
This commit is contained in:
parent
4819ff0358
commit
c74f17d96c
|
@ -94,7 +94,6 @@
|
|||
" <method name=\"KillUnit\">\n" \
|
||||
" <arg name=\"name\" type=\"s\" direction=\"in\"/>\n" \
|
||||
" <arg name=\"who\" type=\"s\" direction=\"in\"/>\n" \
|
||||
" <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
|
||||
" <arg name=\"signal\" type=\"i\" direction=\"in\"/>\n" \
|
||||
" </method>\n" \
|
||||
" <method name=\"ResetFailedUnit\">\n" \
|
||||
|
@ -665,10 +664,9 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
|
|||
reload_if_possible = true;
|
||||
job_type = JOB_TRY_RESTART;
|
||||
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "KillUnit")) {
|
||||
const char *name, *swho, *smode;
|
||||
const char *name, *swho;
|
||||
int32_t signo;
|
||||
Unit *u;
|
||||
KillMode mode;
|
||||
KillWho who;
|
||||
|
||||
if (!dbus_message_get_args(
|
||||
|
@ -676,7 +674,6 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
|
|||
&error,
|
||||
DBUS_TYPE_STRING, &name,
|
||||
DBUS_TYPE_STRING, &swho,
|
||||
DBUS_TYPE_STRING, &smode,
|
||||
DBUS_TYPE_INT32, &signo,
|
||||
DBUS_TYPE_INVALID))
|
||||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
|
@ -689,23 +686,17 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
|
|||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
}
|
||||
|
||||
if (isempty(smode))
|
||||
mode = KILL_CONTROL_GROUP;
|
||||
else {
|
||||
mode = kill_mode_from_string(smode);
|
||||
if (mode < 0)
|
||||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
}
|
||||
|
||||
if (signo <= 0 || signo >= _NSIG)
|
||||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
|
||||
if (!(u = manager_get_unit(m, name))) {
|
||||
u = manager_get_unit(m, name);
|
||||
if (!u) {
|
||||
dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name);
|
||||
return bus_send_error_reply(connection, message, &error, -ENOENT);
|
||||
}
|
||||
|
||||
if ((r = unit_kill(u, who, mode, signo, &error)) < 0)
|
||||
r = unit_kill(u, who, signo, &error);
|
||||
if (r < 0)
|
||||
return bus_send_error_reply(connection, message, &error, r);
|
||||
|
||||
if (!(reply = dbus_message_new_method_return(message)))
|
||||
|
|
|
@ -431,9 +431,8 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
|
|||
reload_if_possible = true;
|
||||
job_type = JOB_TRY_RESTART;
|
||||
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Kill")) {
|
||||
const char *swho, *smode;
|
||||
const char *swho;
|
||||
int32_t signo;
|
||||
KillMode mode;
|
||||
KillWho who;
|
||||
int r;
|
||||
|
||||
|
@ -441,7 +440,6 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
|
|||
message,
|
||||
&error,
|
||||
DBUS_TYPE_STRING, &swho,
|
||||
DBUS_TYPE_STRING, &smode,
|
||||
DBUS_TYPE_INT32, &signo,
|
||||
DBUS_TYPE_INVALID))
|
||||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
|
@ -454,21 +452,15 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
|
|||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
}
|
||||
|
||||
if (isempty(smode))
|
||||
mode = KILL_CONTROL_GROUP;
|
||||
else {
|
||||
mode = kill_mode_from_string(smode);
|
||||
if (mode < 0)
|
||||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
}
|
||||
|
||||
if (signo <= 0 || signo >= _NSIG)
|
||||
return bus_send_error_reply(connection, message, &error, -EINVAL);
|
||||
|
||||
if ((r = unit_kill(u, who, mode, signo, &error)) < 0)
|
||||
r = unit_kill(u, who, signo, &error);
|
||||
if (r < 0)
|
||||
return bus_send_error_reply(connection, message, &error, r);
|
||||
|
||||
if (!(reply = dbus_message_new_method_return(message)))
|
||||
reply = dbus_message_new_method_return(message);
|
||||
if (!reply)
|
||||
goto oom;
|
||||
|
||||
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ResetFailed")) {
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
" </method>\n" \
|
||||
" <method name=\"Kill\">\n" \
|
||||
" <arg name=\"who\" type=\"s\" direction=\"in\"/>\n" \
|
||||
" <arg name=\"mode\" type=\"s\" direction=\"in\"/>\n" \
|
||||
" <arg name=\"signal\" type=\"i\" direction=\"in\"/>\n" \
|
||||
" </method>\n" \
|
||||
" <method name=\"ResetFailed\"/>\n" \
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef struct KillContext KillContext;
|
|||
#include <stdio.h>
|
||||
|
||||
typedef enum KillMode {
|
||||
/* The kill mode is a property of a unit. */
|
||||
KILL_CONTROL_GROUP = 0,
|
||||
KILL_PROCESS,
|
||||
KILL_NONE,
|
||||
|
@ -41,6 +42,7 @@ struct KillContext {
|
|||
};
|
||||
|
||||
typedef enum KillWho {
|
||||
/* Kill who is a property of an operation */
|
||||
KILL_MAIN,
|
||||
KILL_CONTROL,
|
||||
KILL_ALL,
|
||||
|
|
|
@ -1708,7 +1708,7 @@ static void mount_reset_failed(Unit *u) {
|
|||
m->reload_result = MOUNT_SUCCESS;
|
||||
}
|
||||
|
||||
static int mount_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
|
||||
static int mount_kill(Unit *u, KillWho who, int signo, DBusError *error) {
|
||||
Mount *m = MOUNT(u);
|
||||
int r = 0;
|
||||
Set *pid_set = NULL;
|
||||
|
@ -1730,23 +1730,25 @@ static int mount_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
|
|||
if (kill(m->control_pid, signo) < 0)
|
||||
r = -errno;
|
||||
|
||||
if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
|
||||
if (who == KILL_ALL) {
|
||||
int q;
|
||||
|
||||
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
|
||||
pid_set = set_new(trivial_hash_func, trivial_compare_func);
|
||||
if (!pid_set)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Exclude the control pid from being killed via the cgroup */
|
||||
if (m->control_pid > 0)
|
||||
if ((q = set_put(pid_set, LONG_TO_PTR(m->control_pid))) < 0) {
|
||||
if (m->control_pid > 0) {
|
||||
q = set_put(pid_set, LONG_TO_PTR(m->control_pid));
|
||||
if (q < 0) {
|
||||
r = q;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
q = cgroup_bonding_kill_list(UNIT(m)->cgroup_bondings, signo, false, false, pid_set, NULL);
|
||||
if (q < 0)
|
||||
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
}
|
||||
|
||||
finish:
|
||||
|
|
|
@ -3673,7 +3673,7 @@ static void service_reset_failed(Unit *u) {
|
|||
RATELIMIT_RESET(s->start_limit);
|
||||
}
|
||||
|
||||
static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
|
||||
static int service_kill(Unit *u, KillWho who, int signo, DBusError *error) {
|
||||
Service *s = SERVICE(u);
|
||||
int r = 0;
|
||||
Set *pid_set = NULL;
|
||||
|
@ -3700,28 +3700,33 @@ static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
|
|||
if (kill(s->main_pid, signo) < 0)
|
||||
r = -errno;
|
||||
|
||||
if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
|
||||
if (who == KILL_ALL) {
|
||||
int q;
|
||||
|
||||
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
|
||||
pid_set = set_new(trivial_hash_func, trivial_compare_func);
|
||||
if (!pid_set)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Exclude the control/main pid from being killed via the cgroup */
|
||||
if (s->control_pid > 0)
|
||||
if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
|
||||
if (s->control_pid > 0) {
|
||||
q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
|
||||
if (q < 0) {
|
||||
r = q;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->main_pid > 0)
|
||||
if ((q = set_put(pid_set, LONG_TO_PTR(s->main_pid))) < 0) {
|
||||
if (s->main_pid > 0) {
|
||||
q = set_put(pid_set, LONG_TO_PTR(s->main_pid));
|
||||
if (q < 0) {
|
||||
r = q;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
|
||||
if (q < 0)
|
||||
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
}
|
||||
|
||||
finish:
|
||||
|
|
|
@ -2104,7 +2104,7 @@ static void socket_reset_failed(Unit *u) {
|
|||
s->result = SOCKET_SUCCESS;
|
||||
}
|
||||
|
||||
static int socket_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
|
||||
static int socket_kill(Unit *u, KillWho who, int signo, DBusError *error) {
|
||||
Socket *s = SOCKET(u);
|
||||
int r = 0;
|
||||
Set *pid_set = NULL;
|
||||
|
@ -2126,23 +2126,25 @@ static int socket_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
|
|||
if (kill(s->control_pid, signo) < 0)
|
||||
r = -errno;
|
||||
|
||||
if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
|
||||
if (who == KILL_ALL) {
|
||||
int q;
|
||||
|
||||
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
|
||||
pid_set = set_new(trivial_hash_func, trivial_compare_func);
|
||||
if (!pid_set)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Exclude the control pid from being killed via the cgroup */
|
||||
if (s->control_pid > 0)
|
||||
if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
|
||||
if (s->control_pid > 0) {
|
||||
q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
|
||||
if (q < 0) {
|
||||
r = q;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
|
||||
if (q < 0)
|
||||
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
}
|
||||
|
||||
finish:
|
||||
|
|
|
@ -1260,7 +1260,7 @@ static void swap_reset_failed(Unit *u) {
|
|||
s->result = SWAP_SUCCESS;
|
||||
}
|
||||
|
||||
static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *error) {
|
||||
static int swap_kill(Unit *u, KillWho who, int signo, DBusError *error) {
|
||||
Swap *s = SWAP(u);
|
||||
int r = 0;
|
||||
Set *pid_set = NULL;
|
||||
|
@ -1282,23 +1282,25 @@ static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *
|
|||
if (kill(s->control_pid, signo) < 0)
|
||||
r = -errno;
|
||||
|
||||
if (who == KILL_ALL && mode == KILL_CONTROL_GROUP) {
|
||||
if (who == KILL_ALL) {
|
||||
int q;
|
||||
|
||||
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
|
||||
pid_set = set_new(trivial_hash_func, trivial_compare_func);
|
||||
if (!pid_set)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Exclude the control pid from being killed via the cgroup */
|
||||
if (s->control_pid > 0)
|
||||
if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
|
||||
if (s->control_pid > 0) {
|
||||
q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
|
||||
if (q < 0) {
|
||||
r = q;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
|
||||
if (q < 0)
|
||||
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
r = q;
|
||||
}
|
||||
|
||||
finish:
|
||||
|
|
|
@ -2721,20 +2721,16 @@ bool unit_pending_active(Unit *u) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int unit_kill(Unit *u, KillWho w, KillMode m, int signo, DBusError *error) {
|
||||
int unit_kill(Unit *u, KillWho w, int signo, DBusError *error) {
|
||||
assert(u);
|
||||
assert(w >= 0 && w < _KILL_WHO_MAX);
|
||||
assert(m >= 0 && m < _KILL_MODE_MAX);
|
||||
assert(signo > 0);
|
||||
assert(signo < _NSIG);
|
||||
|
||||
if (m == KILL_NONE)
|
||||
return 0;
|
||||
|
||||
if (!UNIT_VTABLE(u)->kill)
|
||||
return -ENOTSUP;
|
||||
|
||||
return UNIT_VTABLE(u)->kill(u, w, m, signo, error);
|
||||
return UNIT_VTABLE(u)->kill(u, w, signo, error);
|
||||
}
|
||||
|
||||
int unit_following_set(Unit *u, Set **s) {
|
||||
|
|
|
@ -293,7 +293,7 @@ struct UnitVTable {
|
|||
int (*stop)(Unit *u);
|
||||
int (*reload)(Unit *u);
|
||||
|
||||
int (*kill)(Unit *u, KillWho w, KillMode m, int signo, DBusError *error);
|
||||
int (*kill)(Unit *u, KillWho w, int signo, DBusError *error);
|
||||
|
||||
bool (*can_reload)(Unit *u);
|
||||
|
||||
|
@ -468,7 +468,7 @@ int unit_start(Unit *u);
|
|||
int unit_stop(Unit *u);
|
||||
int unit_reload(Unit *u);
|
||||
|
||||
int unit_kill(Unit *u, KillWho w, KillMode m, int signo, DBusError *error);
|
||||
int unit_kill(Unit *u, KillWho w, int signo, DBusError *error);
|
||||
|
||||
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success);
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@ static bool arg_failed = false;
|
|||
static bool arg_runtime = false;
|
||||
static char **arg_wall = NULL;
|
||||
static const char *arg_kill_who = NULL;
|
||||
static const char *arg_kill_mode = NULL;
|
||||
static int arg_signal = SIGTERM;
|
||||
static const char *arg_root = NULL;
|
||||
static usec_t arg_when = 0;
|
||||
|
@ -2140,9 +2139,6 @@ static int kill_unit(DBusConnection *bus, char **args) {
|
|||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
|
||||
if (!arg_kill_mode)
|
||||
arg_kill_mode = streq(arg_kill_who, "all") ? "control-group" : "process";
|
||||
|
||||
STRV_FOREACH(name, args+1) {
|
||||
DBusMessage *reply;
|
||||
char *n;
|
||||
|
@ -2163,7 +2159,6 @@ static int kill_unit(DBusConnection *bus, char **args) {
|
|||
b = dbus_message_append_args(m,
|
||||
DBUS_TYPE_STRING, n ? &n : name,
|
||||
DBUS_TYPE_STRING, &arg_kill_who,
|
||||
DBUS_TYPE_STRING, &arg_kill_mode,
|
||||
DBUS_TYPE_INT32, &arg_signal,
|
||||
DBUS_TYPE_INVALID);
|
||||
free(n);
|
||||
|
@ -4593,7 +4588,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
|||
ARG_ROOT,
|
||||
ARG_FULL,
|
||||
ARG_NO_RELOAD,
|
||||
ARG_KILL_MODE,
|
||||
ARG_KILL_WHO,
|
||||
ARG_NO_ASK_PASSWORD,
|
||||
ARG_FAILED,
|
||||
|
@ -4625,7 +4619,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
|||
{ "root", required_argument, NULL, ARG_ROOT },
|
||||
{ "force", no_argument, NULL, ARG_FORCE },
|
||||
{ "no-reload", no_argument, NULL, ARG_NO_RELOAD },
|
||||
{ "kill-mode", required_argument, NULL, ARG_KILL_MODE }, /* undocumented on purpose */
|
||||
{ "kill-who", required_argument, NULL, ARG_KILL_WHO },
|
||||
{ "signal", required_argument, NULL, 's' },
|
||||
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
||||
|
@ -4771,10 +4764,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
|||
arg_kill_who = optarg;
|
||||
break;
|
||||
|
||||
case ARG_KILL_MODE:
|
||||
arg_kill_mode = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if ((arg_signal = signal_from_string_try_harder(optarg)) < 0) {
|
||||
log_error("Failed to parse signal string %s.", optarg);
|
||||
|
|
Loading…
Reference in New Issue