aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-12-14 23:40:44 +0100
committerKenny Levinsen <kl@kl.wtf>2020-12-23 00:34:02 +0100
commit61b086511f86e8cc93528818ec0070c3c02a642f (patch)
treebfcaf480b00b9435bf5f363387860a24fefeef44
parent1ececbbf361a227fa6449f51904f97f37763b5a4 (diff)
logind: Send ReleaseControl when closing seat
This is not strictly speaking necessary as detaching from the bus should trigger this automatically, but elogind apparently has issues with this. Doing this explicitly does no harm, so let's just do that.
-rw-r--r--libseat/backend/logind.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/libseat/backend/logind.c b/libseat/backend/logind.c
index c9a22c0..0ae95b1 100644
--- a/libseat/backend/logind.c
+++ b/libseat/backend/logind.c
@@ -46,6 +46,7 @@ struct backend_logind {
const struct seat_impl logind_impl;
static struct backend_logind *backend_logind_from_libseat_backend(struct libseat *base);
+static void release_control(struct backend_logind *backend);
static void destroy(struct backend_logind *backend) {
assert(backend);
@@ -61,6 +62,7 @@ static void destroy(struct backend_logind *backend) {
static int close_seat(struct libseat *base) {
struct backend_logind *backend = backend_logind_from_libseat_backend(base);
+ release_control(backend);
destroy(backend);
return 0;
}
@@ -280,6 +282,21 @@ static bool take_control(struct backend_logind *session) {
return ret >= 0;
}
+static void release_control(struct backend_logind *session) {
+ sd_bus_message *msg = NULL;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+
+ int ret = sd_bus_call_method(session->bus, "org.freedesktop.login1", session->path,
+ "org.freedesktop.login1.Session", "ReleaseControl", &error,
+ &msg, "");
+ if (ret < 0) {
+ log_errorf("Could not release control of session: %s", error.message);
+ }
+
+ sd_bus_error_free(&error);
+ sd_bus_message_unref(msg);
+}
+
static void set_active(struct backend_logind *backend, bool active) {
if (backend->active == active) {
return;
@@ -652,9 +669,7 @@ static struct libseat *logind_open_seat(struct libseat_seat_listener *listener,
return &backend->base;
error:
- if (backend != NULL) {
- destroy(backend);
- }
+ destroy(backend);
return NULL;
}