kinit/0001-Only-move-XAUTHORITY-if-it-s-temporary.patch

40 lines
1.6 KiB
Diff
Raw Normal View History

From 8040d22c25eb950e8206af7ff20dcd958267de10 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Tue, 13 Mar 2018 18:54:26 +0100
Subject: [PATCH] Only move XAUTHORITY if it's temporary
References: boo#1084798
If kdeinit is started within a session spawned by kdesu or similiar, it has
a temporary file as $XAUTHORITY. As kdeinit is persistent, the used .Xauthority
file must persist as well otherwise launched child process would have no access
to X. kdeinit works around the file's volatileness by copying it to a known
location. Unfortunately the chosen location (/tmp) gets cleared regularly which
means it's even more volatile than the source...
Even more unfortunately, this workaround is applied WAY to broad. Even when
$XAUTHORITY points to a static file, like in a normal user session, it moves
.Xauthority around.
Work around this issue by only applying it if $XAUTHORITY is in /tmp, where
kdesu places it.
---
src/kdeinit/kinit.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kdeinit/kinit.cpp b/src/kdeinit/kinit.cpp
index 0c2c35a..54a390f 100644
--- a/src/kdeinit/kinit.cpp
+++ b/src/kdeinit/kinit.cpp
@@ -1483,7 +1483,7 @@ static void setupX()
as well, point XAUTHORITY there and never remove the file (except for possible
tmp cleanup).
*/
- if (!qEnvironmentVariableIsEmpty("XAUTHORITY")) {
+ if (!qEnvironmentVariableIsEmpty("XAUTHORITY") && qgetenv("XAUTHORITY").startsWith("/tmp/")) {
QByteArray display = qgetenv(displayEnvVarName_c());
int i;
if ((i = display.lastIndexOf('.')) > display.lastIndexOf(':') && i >= 0) {
--
2.16.2