diff --git a/0416-libkworkspace-Only-update-env-vars-with-alphanumeric.patch b/0416-libkworkspace-Only-update-env-vars-with-alphanumeric.patch new file mode 100644 index 0000000..2cf9895 --- /dev/null +++ b/0416-libkworkspace-Only-update-env-vars-with-alphanumeric.patch @@ -0,0 +1,68 @@ +From 10780187f57ab6e68fa08386321f2d0274b951df Mon Sep 17 00:00:00 2001 +From: Jonas Lundholm Bertelsen +Date: Wed, 13 Jan 2021 01:29:44 +0100 +Subject: [PATCH 416/419] [libkworkspace] Only update env vars with + alphanumeric_ names + +It gives issues with systemd to try and pass it env var names with eg. +'%' in them. That to such a degree that if invalid names are passed, +none are set [1]. This change ensures compatibility by skipping any +non-alphanumerical (and _) variable names. + +[1] https://bugzilla.redhat.com/show_bug.cgi?id=1754395 +--- + libkworkspace/updatelaunchenvjob.cpp | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/libkworkspace/updatelaunchenvjob.cpp b/libkworkspace/updatelaunchenvjob.cpp +index f01a4c144..b7e124c71 100644 +--- a/libkworkspace/updatelaunchenvjob.cpp ++++ b/libkworkspace/updatelaunchenvjob.cpp +@@ -28,6 +28,7 @@ public: + explicit Private(UpdateLaunchEnvJob *q); + void monitorReply(const QDBusPendingReply<> &reply); + ++ static bool isPosixName(const QString &name); + static bool isSystemdApprovedValue(const QString &value); + + UpdateLaunchEnvJob *q; +@@ -82,6 +83,10 @@ void UpdateLaunchEnvJob::start() + QStringList systemdUpdates; + + for (const auto &varName : d->environment.keys()) { ++ if (!Private::isPosixName(varName)){ ++ qWarning() << "Skipping syncing of environment variable " << varName << "as name contains unsupported characters"; ++ continue; ++ } + const QString value = d->environment.value(varName); + + // KLauncher +@@ -136,6 +141,25 @@ void UpdateLaunchEnvJob::start() + d->monitorReply(systemdActivationReply); + } + ++bool UpdateLaunchEnvJob::Private::isPosixName(const QString &name) ++{ ++ // Posix says characters like % should be 'tolerated', but it gives issues in practice. ++ // https://bugzilla.redhat.com/show_bug.cgi?id=1754395 ++ // https://bugzilla.redhat.com/show_bug.cgi?id=1879216 ++ // Ensure systemd compat by only allowing alphanumerics and _ in names. ++ bool first = true; ++ for (const QChar c : name) { ++ if (first && !c.isLetter() && c != QChar('_')) { ++ return false; ++ } else if (first) { ++ first = false; ++ } else if (!c.isLetterOrNumber() && c != QChar('_')) { ++ return false; ++ } ++ } ++ return !first; ++} ++ + bool UpdateLaunchEnvJob::Private::isSystemdApprovedValue(const QString &value) + { + // systemd code checks that a value contains no control characters except \n \t +-- +2.29.2 + diff --git a/plasma-workspace-5.18.4.1-filter-environment-v2.patch b/plasma-workspace-5.18.4.1-filter-environment-v2.patch deleted file mode 100644 index fe79f7c..0000000 --- a/plasma-workspace-5.18.4.1-filter-environment-v2.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff -r -U3 plasma-workspace-5.18.4.1.orig/startkde/startplasma.cpp plasma-workspace-5.18.4.1/startkde/startplasma.cpp ---- plasma-workspace-5.18.4.1.orig/startkde/startplasma.cpp 2020-03-31 17:33:37.000000000 +0300 -+++ plasma-workspace-5.18.4.1/startkde/startplasma.cpp 2020-04-03 20:43:32.178541309 +0300 -@@ -28,6 +28,9 @@ - #include - #include - -+#include -+#include -+ - #include - #include - -@@ -64,8 +66,26 @@ - int runSync(const QString& program, const QStringList &args, const QStringList &env) - { - QProcess p; -- if (!env.isEmpty()) -- p.setEnvironment(QProcess::systemEnvironment() << env); -+ auto pEnv = QProcessEnvironment::systemEnvironment(); -+ if (!env.isEmpty()) { -+ for (const auto &value : env) { -+ int pos = value.indexOf(QStringLiteral("=")); -+ if (pos != -1) { -+ pEnv.insert(value.left(pos), value.mid(pos+1)); -+ } -+ } -+ } -+ if (program.endsWith(QStringLiteral("dbus-update-activation-environment"))) { -+ const QRegularExpression re(QStringLiteral("[^A-Z0-9_]")); -+ for (const auto &key : pEnv.keys()) { -+ const auto match = re.match(key); -+ if (match.hasMatch()) { -+ pEnv.remove(key); -+ qInfo() << "program:" << program << "environment variable removed:" << key; -+ } -+ } -+ } -+ p.setProcessEnvironment(pEnv); - p.setProcessChannelMode(QProcess::ForwardedChannels); - p.start(program, args); - // qDebug() << "started..." << program << args; diff --git a/plasma-workspace.spec b/plasma-workspace.spec index 271ae70..a898148 100644 --- a/plasma-workspace.spec +++ b/plasma-workspace.spec @@ -16,7 +16,7 @@ Name: plasma-workspace Summary: Plasma workspace, applications and applets Version: 5.20.5 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ URL: https://cgit.kde.org/%{name}.git @@ -51,14 +51,13 @@ Patch101: plasma-workspace-5.3.0-set-fedora-default-look-and-feel.patch # and example, # https://github.com/notmart/artwork-lnf-netrunner-core/blob/master/usr/share/plasma/look-and-feel/org.kde.netrunner-core.desktop/contents/defaults Patch105: plasma-workspace-5.7.3-folderview_layout.patch -# workaround https://bugzilla.redhat.com/show_bug.cgi?id=1754395 -Patch106: plasma-workspace-5.18.4.1-filter-environment-v2.patch ## upstreamable Patches ## upstream Patches lookaside cache ## upstream Patches (master branch) +Patch416: 0416-libkworkspace-Only-update-env-vars-with-alphanumeric.patch # udev BuildRequires: zlib-devel @@ -404,6 +403,7 @@ BuildArch: noarch %setup -q -a 20 ## upstream patches +%patch416 -p1 -b 0416 %patch100 -p1 -b .konsole-in-contextmenu # FIXME/TODO: it is unclear whether this is needed or even a good idea anymore -- rex @@ -413,7 +413,6 @@ sed -i -e "s|@DEFAULT_LOOKANDFEEL@|%{?default_lookandfeel}%{!?default_lookandfee shell/packageplugins/lookandfeel/lookandfeel.cpp %endif %patch105 -p1 -%patch106 -p1 -b .bz1754395 %if 0%{?fedora} cp -a lookandfeel lookandfeel-fedora @@ -701,6 +700,9 @@ desktop-file-validate %{buildroot}%{_kf5_datadir}/applications/org.kde.{klipper, %changelog +* Thu Jan 14 2021 Rex Dieter - 5.20.5-3 +- pull in upstream fix for sanitized user environment (#1754395) + * Thu Jan 14 10:43:00 CET 2021 Jan Grulich - 5.20.5-2 - Rebuild (gpsd)