File 0001-Fix-writing-ICEAuthority-file.patch of Package plasma6-workspace
From 918cb38c3522ffcc241ac6a22b6741e41cdd3c30 Mon Sep 17 00:00:00 2001
From: David Edmundson <david@davidedmundson.co.uk>
Date: Sun, 9 Jun 2024 08:25:11 +0000
Subject: [PATCH] Fix writing ICEAuthority file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 9398f6cf8933055b31506ba155aef2fc2b3561d7 "Remove iceauth
dependency" introduced two bugs:
1) "fp" is never closed, so the generated auth data stays buffered in
memory for some indeterminate time and the file stays empty on disk.
This completely breaks authentication and thus also session restore.
2) Checking the return value of IceWriteAuthFileEntry() is inverted (the
function returns non-zero on success), so warnings are printed iff
everything goes well.
BUG: 487912
(cherry picked from commit 0dcf34458d99b07a3d9054ae0c86c656e0dfa7aa)
Co-authored-by: Tomáš Trnka <tomastrnka@gmx.com>
---
ksmserver/server.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp
index 84b82b4851..493bed5016 100644
--- a/ksmserver/server.cpp
+++ b/ksmserver/server.cpp
@@ -364,7 +364,7 @@ Status SetAuthentication(int count, IceListenObj *listenObjs, IceAuthDataEntry *
file_entry->auth_name = strdup("MIT-MAGIC-COOKIE-1");
file_entry->auth_data = strdup((*authDataEntries)[i].auth_data);
file_entry->auth_data_length = MAGIC_COOKIE_LEN;
- if (IceWriteAuthFileEntry(fp, file_entry) != 0) {
+ if (IceWriteAuthFileEntry(fp, file_entry) == 0) {
qWarning("Failed to write ice auth file entry");
}
IceFreeAuthFileEntry(file_entry);
@@ -388,7 +388,7 @@ Status SetAuthentication(int count, IceListenObj *listenObjs, IceAuthDataEntry *
file_entry->auth_name = strdup("MIT-MAGIC-COOKIE-1");
file_entry->auth_data = strdup((*authDataEntries)[i + 1].auth_data);
file_entry->auth_data_length = MAGIC_COOKIE_LEN;
- if (IceWriteAuthFileEntry(fp, file_entry) != 0) {
+ if (IceWriteAuthFileEntry(fp, file_entry) == 0) {
qWarning("Failed to write xsmp ice auth file entry");
}
IceFreeAuthFileEntry(file_entry);
@@ -397,6 +397,11 @@ Status SetAuthentication(int count, IceListenObj *listenObjs, IceAuthDataEntry *
IceSetPaAuthData(2, &(*authDataEntries)[i]);
}
+ if (fclose(fp) != 0) {
+ qWarning() << "Could not close ICEAuthority file";
+ return 0;
+ }
+
return (1);
}
--
2.45.1