File 0001-Move-Xauthority-to-a-different-location-and-truncate.patch of Package sddm

From 87ff59b5558c3df9384a1d55590a53b9aca74bd0 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Thu, 30 Nov 2017 13:38:27 +0100
Subject: [PATCH] Move Xauthority to a different location and truncate it again

When the hostname changes, started X applications try the new hostname
first. If a cookie is found for that new hostname, they try to authenticate
(which fails) and exit. So .Xauthority must not contain old cookies.
Truncating ~/.Xauthority breaks ssh forwarding though, so the default
location is changed to something sddm specific.
As it's not possible to login twice as the same user simultaneously,
a fixed path at a fixed location is enough.

Issue #944
---
 data/man/sddm.conf.rst.in        | 2 +-
 src/common/Configuration.h       | 2 +-
 src/daemon/XorgDisplayServer.cpp | 7 +++++--
 src/helper/UserSession.cpp       | 4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)

Index: sddm-0.17.0/data/man/sddm.conf.rst.in
===================================================================
--- sddm-0.17.0.orig/data/man/sddm.conf.rst.in
+++ sddm-0.17.0/data/man/sddm.conf.rst.in
@@ -119,7 +119,7 @@ OPTIONS
 
 `UserAuthFile=`
         Path to the Xauthority file, relative to the home directory.
-        Default value is ".Xauthority".
+        Default value is ".local/share/sddm/.Xauthority".
 
 `DisplayCommand=`
 	Path of script to execute when starting the display server.
Index: sddm-0.17.0/src/common/Configuration.h
===================================================================
--- sddm-0.17.0.orig/src/common/Configuration.h
+++ sddm-0.17.0/src/common/Configuration.h
@@ -65,7 +65,7 @@ namespace SDDM {
             Entry(SessionDir,          QString,     _S("/usr/share/xsessions"),                 _S("Directory containing available X sessions"));
             Entry(SessionCommand,      QString,     _S(SESSION_COMMAND),                        _S("Path to a script to execute when starting the desktop session"));
 	    Entry(SessionLogFile,      QString,     _S(".local/share/sddm/xorg-session.log"),   _S("Path to the user session log file"));
-	    Entry(UserAuthFile,        QString,     _S(".Xauthority"),                          _S("Path to the Xauthority file"));
+	    Entry(UserAuthFile,        QString,     _S(".local/share/sddm/.Xauthority"),        _S("Path to the Xauthority file"));
             Entry(DisplayCommand,      QString,     _S(DATA_INSTALL_DIR "/scripts/Xsetup"),     _S("Path to a script to execute when starting the display server"));
             Entry(DisplayStopCommand,  QString,     _S(DATA_INSTALL_DIR "/scripts/Xstop"),      _S("Path to a script to execute when stopping the display server"));
             Entry(MinimumVT,           int,         MINIMUM_VT,                                 _S("The lowest virtual terminal number that will be used."));
Index: sddm-0.17.0/src/daemon/XorgDisplayServer.cpp
===================================================================
--- sddm-0.17.0.orig/src/daemon/XorgDisplayServer.cpp
+++ sddm-0.17.0/src/daemon/XorgDisplayServer.cpp
@@ -91,9 +91,12 @@ namespace SDDM {
         // log message
         qDebug() << "Adding cookie to" << file;
 
-        // Touch file
+        // Create and truncate the file
+        QFileInfo finfo(file);
+        QDir().mkpath(finfo.absolutePath());
+
         QFile file_handler(file);
-        file_handler.open(QIODevice::Append);
+        file_handler.open(QIODevice::WriteOnly);
         file_handler.close();
 
         QString cmd = QStringLiteral("%1 -f %2 -q").arg(mainConfig.X11.XauthPath.get()).arg(file);
Index: sddm-0.17.0/src/helper/UserSession.cpp
===================================================================
--- sddm-0.17.0.orig/src/helper/UserSession.cpp
+++ sddm-0.17.0/src/helper/UserSession.cpp
@@ -174,12 +174,12 @@ namespace SDDM {
             qDebug() << "Adding cookie to" << file;
 
 
-            // create the path
+            // Create and truncate the file
             QFileInfo finfo(file);
             QDir().mkpath(finfo.absolutePath());
 
             QFile file_handler(file);
-            file_handler.open(QIODevice::Append);
+            file_handler.open(QIODevice::WriteOnly);
             file_handler.close();
 
             QString cmd = QStringLiteral("%1 -f %2 -q").arg(mainConfig.X11.XauthPath.get()).arg(file);
openSUSE Build Service is sponsored by