[neon/kde/kglobalaccel/Neon/release-lts] debian/patches: add patch recommended by dev

Jonathan Riddell null at kde.org
Fri Mar 26 13:30:48 GMT 2021


Git commit 94388eb71e5136da2c02585147d2b0192bc77a9e by Jonathan Riddell.
Committed on 26/03/2021 at 13:30.
Pushed by jriddell into branch 'Neon/release-lts'.

add patch recommended by dev

A  +2    -0    debian/patches/series
A  +38   -0    debian/patches/uid.diff
A  +47   -0    debian/patches/uid2.diff

https://invent.kde.org/neon/kde/kglobalaccel/commit/94388eb71e5136da2c02585147d2b0192bc77a9e

diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..2ade593
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+uid.diff
+uid2.diff
diff --git a/debian/patches/uid.diff b/debian/patches/uid.diff
new file mode 100644
index 0000000..2243488
--- /dev/null
+++ b/debian/patches/uid.diff
@@ -0,0 +1,38 @@
+commit bbec74337b3186bc258bd5adf849b89191789535
+Author: Fabian Vogt <fabian at ritter-vogt.de>
+Date:   Fri Jan 29 11:31:54 2021 +0100
+
+    Don't let kglobalaccel run if KDE_SESSION_UID mismatches
+    
+    Otherwise shortcuts execute actions as the wrong user.
+
+diff --git a/src/runtime/main.cpp b/src/runtime/main.cpp
+index d2917ad..46506b3 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 <KAboutData>
+ #include <KCrash>
+ #include <KDBusService>
+@@ -57,6 +59,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);
diff --git a/debian/patches/uid2.diff b/debian/patches/uid2.diff
new file mode 100644
index 0000000..1187ce7
--- /dev/null
+++ b/debian/patches/uid2.diff
@@ -0,0 +1,47 @@
+commit 33bd15697220f8a1223117fee8b03506fe87d912
+Author: Fabian Vogt <fabian at ritter-vogt.de>
+Date:   Fri Mar 26 13:48:01 2021 +0100
+
+    Only use unistd/getuid when available
+    
+    To fix build on Windows.
+
+diff --git a/src/runtime/main.cpp b/src/runtime/main.cpp
+index 46506b3..380b1b8 100644
+--- a/src/runtime/main.cpp
++++ b/src/runtime/main.cpp
+@@ -10,14 +10,16 @@
+ #include "kglobalacceld.h"
+ #include "logging_p.h"
+ 
+-#include <unistd.h>
+-
+ #include <KAboutData>
+ #include <KCrash>
+ #include <KDBusService>
+ #include <QCommandLineParser>
+ #include <QGuiApplication>
+ 
++#ifdef Q_OS_UNIX
++#include <unistd.h>
++#endif
++
+ static bool isEnabled()
+ {
+     // TODO: Check if kglobalaccel can be disabled
+@@ -59,6 +61,7 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
+         return 0;
+     }
+ 
++#ifdef Q_OS_UNIX
+     // 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.
+@@ -68,6 +71,7 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
+         qCWarning(KGLOBALACCELD) << "kglobalaccel running as wrong user, exiting.";
+         return 0;
+     }
++#endif
+ 
+     KDBusService service(KDBusService::Unique);
+ 


More information about the Neon-commits mailing list