logind: always kill session when termination is requested

KillUserProcesses=yes/no should be ignored when termination is
explicitly requested.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2014-02-08 20:29:56 -05:00
parent 4daf54a851
commit 9bb69af4f2
11 changed files with 25 additions and 25 deletions

View file

@ -939,7 +939,7 @@ static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void *
if (!session)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name);
r = session_stop(session);
r = session_stop(session, true);
if (r < 0)
return r;
@ -964,7 +964,7 @@ static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *use
if (!user)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid);
r = user_stop(user);
r = user_stop(user, true);
if (r < 0)
return r;
@ -989,7 +989,7 @@ static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *use
if (!seat)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name);
r = seat_stop_sessions(seat);
r = seat_stop_sessions(seat, true);
if (r < 0)
return r;

View file

@ -201,7 +201,7 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata
assert(message);
assert(s);
r = seat_stop_sessions(s);
r = seat_stop_sessions(s, true);
if (r < 0)
return r;

View file

@ -418,7 +418,7 @@ int seat_start(Seat *s) {
return 0;
}
int seat_stop(Seat *s) {
int seat_stop(Seat *s, bool force) {
int r = 0;
assert(s);
@ -430,7 +430,7 @@ int seat_stop(Seat *s) {
"MESSAGE=Removed seat %s.", s->id,
NULL);
seat_stop_sessions(s);
seat_stop_sessions(s, force);
unlink(s->state_file);
seat_add_to_gc_queue(s);
@ -443,14 +443,14 @@ int seat_stop(Seat *s) {
return r;
}
int seat_stop_sessions(Seat *s) {
int seat_stop_sessions(Seat *s, bool force) {
Session *session;
int r = 0, k;
assert(s);
LIST_FOREACH(sessions_by_seat, session, s->sessions) {
k = session_stop(session);
k = session_stop(session, force);
if (k < 0)
r = k;
}

View file

@ -80,8 +80,8 @@ bool seat_can_graphical(Seat *s);
int seat_get_idle_hint(Seat *s, dual_timestamp *t);
int seat_start(Seat *s);
int seat_stop(Seat *s);
int seat_stop_sessions(Seat *s);
int seat_stop(Seat *s, bool force);
int seat_stop_sessions(Seat *s, bool force);
bool seat_check_gc(Seat *s, bool drop_not_started);
void seat_add_to_gc_queue(Seat *s);

View file

@ -188,7 +188,7 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata
assert(message);
assert(s);
r = session_stop(s);
r = session_stop(s, true);
if (r < 0)
return r;

View file

@ -565,7 +565,7 @@ int session_start(Session *s) {
return 0;
}
static int session_stop_scope(Session *s) {
static int session_stop_scope(Session *s, bool force) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
char *job;
int r;
@ -575,7 +575,7 @@ static int session_stop_scope(Session *s) {
if (!s->scope)
return 0;
if (manager_shall_kill(s->manager, s->user->name)) {
if (force || manager_shall_kill(s->manager, s->user->name)) {
r = manager_stop_unit(s->manager, s->scope, &error, &job);
if (r < 0) {
log_error("Failed to stop session scope: %s", bus_error_message(&error, r));
@ -595,7 +595,7 @@ static int session_stop_scope(Session *s) {
return 0;
}
int session_stop(Session *s) {
int session_stop(Session *s, bool force) {
int r;
assert(s);
@ -609,7 +609,7 @@ int session_stop(Session *s) {
session_remove_fifo(s);
/* Kill cgroup */
r = session_stop_scope(s);
r = session_stop_scope(s, force);
s->stopping = true;
@ -672,7 +672,7 @@ static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *us
assert(es);
assert(s);
session_stop(s);
session_stop(s, false);
return 0;
}
@ -812,7 +812,7 @@ static int session_dispatch_fifo(sd_event_source *es, int fd, uint32_t revents,
/* EOF on the FIFO means the session died abnormally. */
session_remove_fifo(s);
session_stop(s);
session_stop(s, false);
return 1;
}

View file

@ -136,7 +136,7 @@ int session_get_idle_hint(Session *s, dual_timestamp *t);
void session_set_idle_hint(Session *s, bool b);
int session_create_fifo(Session *s);
int session_start(Session *s);
int session_stop(Session *s);
int session_stop(Session *s, bool force);
int session_finalize(Session *s);
void session_release(Session *s);
int session_save(Session *s);

View file

@ -180,7 +180,7 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata
assert(message);
assert(u);
r = user_stop(u);
r = user_stop(u, true);
if (r < 0)
return r;

View file

@ -494,13 +494,13 @@ static int user_remove_runtime_path(User *u) {
return r;
}
int user_stop(User *u) {
int user_stop(User *u, bool force) {
Session *s;
int r = 0, k;
assert(u);
LIST_FOREACH(sessions_by_user, s, u->sessions) {
k = session_stop(s);
k = session_stop(s, force);
if (k < 0)
r = k;
}

View file

@ -72,7 +72,7 @@ void user_free(User *u);
bool user_check_gc(User *u, bool drop_not_started);
void user_add_to_gc_queue(User *u);
int user_start(User *u);
int user_stop(User *u);
int user_stop(User *u, bool force);
int user_finalize(User *u);
UserState user_get_state(User *u);
int user_get_idle_hint(User *u, dual_timestamp *t);

View file

@ -862,7 +862,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
seat->in_gc_queue = false;
if (!seat_check_gc(seat, drop_not_started)) {
seat_stop(seat);
seat_stop(seat, false);
seat_free(seat);
}
}
@ -874,7 +874,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
/* First, if we are not closing yet, initiate stopping */
if (!session_check_gc(session, drop_not_started) &&
session_get_state(session) != SESSION_CLOSING)
session_stop(session);
session_stop(session, false);
/* Normally, this should make the session busy again,
* if it doesn't then let's get rid of it
@ -891,7 +891,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
if (!user_check_gc(user, drop_not_started) &&
user_get_state(user) != USER_CLOSING)
user_stop(user);
user_stop(user, false);
if (!user_check_gc(user, drop_not_started)) {
user_finalize(user);