File 0001-Don-t-let-kglobalaccel-run-if-KDE_SESSION_UID-mismat.patch of Package kglobalaccel.21271
From fcf8db6e81333f27abcb9da56bebb29c921e2efc Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Fri, 29 Jan 2021 11:31:54 +0100
Subject: [PATCH] Don't let kglobalaccel run if KDE_SESSION_UID mismatches
Otherwise shortcuts execute actions as the wrong user.
(cherry picked from commit bbec74337b3186bc258bd5adf849b89191789535)
---
src/runtime/main.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/runtime/main.cpp b/src/runtime/main.cpp
index ddfe3d9..7e7ae73 100644
--- a/src/runtime/main.cpp
+++ b/src/runtime/main.cpp
@@ -10,6 +10,8 @@
#include "kglobalacceld.h"
#include "logging_p.h"
+#include <unistd.h>
+
#include <KCrash>
#include <KAboutData>
#include <KDBusService>
@@ -58,6 +60,16 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
return 0;
}
+ // It's possible that kglobalaccel gets started as the wrong user by
+ // accident, e.g. kdesu dolphin leads to dbus activation. It then installs
+ // its grabs and the actions are run as the wrong user.
+ bool isUidset = false;
+ const int sessionuid = qEnvironmentVariableIntValue("KDE_SESSION_UID", &isUidset);
+ if(isUidset && static_cast<uid_t>(sessionuid) != getuid()) {
+ qCWarning(KGLOBALACCELD) << "kglobalaccel running as wrong user, exiting.";
+ return 0;
+ }
+
KDBusService service(KDBusService::Unique);
app.setQuitOnLastWindowClosed( false );
--
2.33.0