File 0001-Export-consistent-hostname-as-XAUTHLOCALHOSTNAME.patch of Package kwin5
From 6166db42a61d80a3d8202162c598d1476572f5a1 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Wed, 18 Aug 2021 18:38:18 +0200
Subject: [PATCH] Export consistent hostname as XAUTHLOCALHOSTNAME
To deal with hostname changes, FamilyWild is used for Xauthority, but for Xsm
XAUTHLOCALHOSTNAME is also set (boo#1177835, downstream patch in xtrans).
The hostname is read once on startup and then used consistently.
---
src/helpers/wayland_wrapper/kwin_wrapper.cpp | 6 +++++-
src/xwl/lib/xauthority.cpp | 3 +--
src/xwl/lib/xauthority.h | 3 ++-
3 files changed, 8 insertions(+), 4 deletions(-)
Index: kwin-5.17.80git.20211202T160310~4d7f1d135/src/helpers/wayland_wrapper/kwin_wrapper.cpp
===================================================================
--- kwin-5.17.80git.20211202T160310~4d7f1d135.orig/src/helpers/wayland_wrapper/kwin_wrapper.cpp 2021-12-02 15:03:10.000000000 +0100
+++ kwin-5.17.80git.20211202T160310~4d7f1d135/src/helpers/wayland_wrapper/kwin_wrapper.cpp 2021-12-03 05:59:35.170481723 +0100
@@ -22,6 +22,7 @@
#include <QCoreApplication>
#include <QDebug>
+#include <QHostInfo>
#include <QProcess>
#include <QTemporaryFile>
#include <QDBusConnection>
@@ -70,8 +71,11 @@
}
if (m_xwlSocket) {
if (!qEnvironmentVariableIsSet("KWIN_WAYLAND_NO_XAUTHORITY")) {
- if (!generateXauthorityFile(m_xwlSocket->display(), &m_xauthorityFile)) {
+ const QByteArray hostname = QHostInfo::localHostName().toUtf8();
+ if (!generateXauthorityFile(m_xwlSocket->display(), &m_xauthorityFile, hostname)) {
qCWarning(KWIN_WRAPPER) << "Failed to create an Xauthority file";
+ } else {
+ qputenv("XAUTHLOCALHOSTNAME", hostname);
}
}
}
Index: kwin-5.17.80git.20211202T160310~4d7f1d135/src/xwl/lib/xauthority.cpp
===================================================================
--- kwin-5.17.80git.20211202T160310~4d7f1d135.orig/src/xwl/lib/xauthority.cpp 2021-12-02 15:03:10.000000000 +0100
+++ kwin-5.17.80git.20211202T160310~4d7f1d135/src/xwl/lib/xauthority.cpp 2021-12-03 05:59:35.170481723 +0100
@@ -45,7 +45,7 @@
return cookie;
}
-bool generateXauthorityFile(int display, QTemporaryFile *authorityFile)
+bool generateXauthorityFile(int display, QTemporaryFile *authorityFile, const QByteArray &hostname)
{
const QString runtimeDirectory = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
@@ -54,7 +54,6 @@
return false;
}
- const QByteArray hostname = QHostInfo::localHostName().toUtf8();
const QByteArray displayName = QByteArray::number(display);
const QByteArray name = QByteArrayLiteral("MIT-MAGIC-COOKIE-1");
const QByteArray cookie = generateXauthorityCookie();
Index: kwin-5.17.80git.20211202T160310~4d7f1d135/src/xwl/lib/xauthority.h
===================================================================
--- kwin-5.17.80git.20211202T160310~4d7f1d135.orig/src/xwl/lib/xauthority.h 2021-12-02 15:03:10.000000000 +0100
+++ kwin-5.17.80git.20211202T160310~4d7f1d135/src/xwl/lib/xauthority.h 2021-12-03 05:59:35.170481723 +0100
@@ -9,6 +9,7 @@
#pragma once
+class QByteArray;
class QTemporaryFile;
-bool generateXauthorityFile(int display, QTemporaryFile *authorityFile);
+bool generateXauthorityFile(int display, QTemporaryFile *authorityFile, const QByteArray &hostname);