From 61b086511f86e8cc93528818ec0070c3c02a642f Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 14 Dec 2020 23:40:44 +0100 Subject: 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. --- libseat/backend/logind.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'libseat') 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; } -- cgit v1.2.3