File 0005-If-autologin-is-used-avoid-starting-a-display-server.patch of Package sddm

From 080f38676b1c9e1596effb0ff39c8d1f96775a89 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Mon, 15 Jul 2024 21:23:53 +0200
Subject: [PATCH 5/5] If autologin is used, avoid starting a display server for
 the greeter

Introduce a new "early autologin" path that starts the session without
starting the display server first. This avoids starting a rootful X just
to then ignore it and start a Wayland session in a separate VT.
---
 src/daemon/Display.cpp | 29 ++++++++++++++++++++++++++---
 src/daemon/Display.h   |  2 +-
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp
index 9167ebf..e10977e 100644
--- a/src/daemon/Display.cpp
+++ b/src/daemon/Display.cpp
@@ -231,6 +231,18 @@ namespace SDDM {
 
         m_started = true;
 
+        // Handle autologin early, unless it needs the display server to be up
+        // (rootful X + X11 autologin session).
+        if (m_autologinSession.isValid()
+            && !(m_displayServerType == X11DisplayServerType
+                 && m_autologinSession.type() == Session::X11Session)) {
+            m_auth->setAutologin(true);
+            if (startAuth(mainConfig.Autologin.User.get(), QString(), m_autologinSession))
+                return true;
+            else
+                return handleAutologinFailure();
+         }
+
         return m_displayServer->start();
     }
 
@@ -256,10 +268,17 @@ namespace SDDM {
         m_greeter->start();
     }
 
-    void Display::handleAutologinFailure() {
+    bool Display::handleAutologinFailure() {
         qWarning() << "Autologin failed!";
         m_auth->setAutologin(false);
-        startSocketServerAndGreeter();
+        // For late autologin handling only the greeter needs to be started.
+        if (m_displayServerType == X11DisplayServerType
+            && m_autologinSession.type() == Session::X11Session) {
+            startSocketServerAndGreeter();
+            return true;
+        } else {
+            return m_displayServer->start();
+        }
     }
 
     void Display::displayServerStarted() {
@@ -269,7 +288,11 @@ namespace SDDM {
         // log message
         qDebug() << "Display server started.";
 
-        if (m_autologinSession.isValid()) {
+        // Handle autologin late if it needs the display server to be up
+        // (rootful X + X11 autologin session).
+        if (m_autologinSession.isValid()
+            && (m_displayServerType == X11DisplayServerType
+                && m_autologinSession.type() == Session::X11Session)) {
             m_auth->setAutologin(true);
             if (!startAuth(mainConfig.Autologin.User.get(), QString(), m_autologinSession))
                 handleAutologinFailure();
diff --git a/src/daemon/Display.h b/src/daemon/Display.h
index d0b23c4..c2741ea 100644
--- a/src/daemon/Display.h
+++ b/src/daemon/Display.h
@@ -89,7 +89,7 @@ namespace SDDM {
                        const Session &session);
 
         void startSocketServerAndGreeter();
-        void handleAutologinFailure();
+        bool handleAutologinFailure();
 
         DisplayServerType m_displayServerType = X11DisplayServerType;
 
-- 
2.46.0

openSUSE Build Service is sponsored by