From 3e2a558adba4d46aafe3d2483be28dbc42b76d17 Mon Sep 17 00:00:00 2001 From: April & May & June Date: Mon, 5 Jan 2026 14:46:20 +0800 Subject: [PATCH] fix: fix user cannot login after logout once We manually stop the auth before terminating logind session, so that the session can be closed properly by PAM without being left in an undetermined state. --- src/daemon/Auth.cpp | 5 ++--- src/daemon/Display.cpp | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/daemon/Auth.cpp b/src/daemon/Auth.cpp index 7276eb5..f998c51 100644 --- a/src/daemon/Auth.cpp +++ b/src/daemon/Auth.cpp @@ -199,6 +199,8 @@ namespace DDM { return; active = false; qint64 pid = m_session->processId(); + QString vt = m_env.value(QStringLiteral("XDG_VTNR")); + QString displayId = m_env.value(QStringLiteral("DISPLAY")); if (m_session->state() != QProcess::NotRunning) m_session->stop(); if (m_pam->sessionOpened) @@ -206,9 +208,6 @@ namespace DDM { // write logout to utmp/wtmp if (pid > 0) { - QProcessEnvironment env = m_session->processEnvironment(); - QString vt = env.value(QStringLiteral("XDG_VTNR")); - QString displayId = env.value(QStringLiteral("DISPLAY")); utmpLogout(vt, displayId, pid); } } diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp index 162ebb8..a209870 100644 --- a/src/daemon/Display.cpp +++ b/src/daemon/Display.cpp @@ -348,6 +348,9 @@ namespace DDM { } void Display::logout([[maybe_unused]] QLocalSocket *socket, int id) { + for (Auth *auth : std::as_const(auths)) + if (auth->xdgSessionId == id) + auth->stop(); OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(), Logind::managerPath(), QDBusConnection::systemBus()); manager.TerminateSession(QString::number(id)); }