From f0e551925a70a4d2afde4a28119f969ecf2c754a Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sun, 18 Dec 2016 17:54:14 +0100 Subject: [PATCH] [Icon Applet] Don't copy application .desktop files to plasma_icons if run_desktop_files restriction is enforced When this restriction is enabled, KIO will refuse to run desktop files outside system-known locations essentially breaking the icon widgetin this case. Since we still want to be able to have shortcuts in locked-down setups, let's just use the source desktop file in this case and rather lose the ability to customize it (which isn't really possible with this restrition anyway) --- applets/icon/iconapplet.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/applets/icon/iconapplet.cpp b/applets/icon/iconapplet.cpp index 5ce03da3d..3624e5d5e 100644 --- a/applets/icon/iconapplet.cpp +++ b/applets/icon/iconapplet.cpp @@ -107,6 +107,16 @@ void IconApplet::populate() // if desktop file just copy it over if (KDesktopFile::isDesktopFile(localUrlString)) { + // if this restriction is set, KIO won't allow running desktop files from outside + // registered services, applications, and so on, in this case we'll use the original + // .desktop file and lose the ability to customize it + if (!KAuthorized::authorize(QStringLiteral("run_desktop_files"))) { + populateFromDesktopFile(localUrlString); + // we don't call setLocalPath here as we don't want to store localPath to be a system-location + // so that the fact that we cannot edit is re-evaluated every time + return; + } + if (!QFile::copy(localUrlString, backingDesktopFile)) { setLaunchErrorMessage(i18n("Failed to copy icon widget desktop file from '%1' to '%2'", localUrlString, backingDesktopFile)); return;