diff options
Diffstat (limited to 'kde-frameworks/kio')
-rw-r--r-- | kde-frameworks/kio/Manifest | 4 | ||||
-rw-r--r-- | kde-frameworks/kio/files/kio-5.74.1-handle-shell-scripts-consistenty.patch | 310 | ||||
-rw-r--r-- | kde-frameworks/kio/files/kio-5.74.1-kio_trash-too-strict-perms-check.patch | 67 | ||||
-rw-r--r-- | kde-frameworks/kio/kio-5.74.1-r1.ebuild (renamed from kde-frameworks/kio/kio-5.74.1.ebuild) | 5 |
4 files changed, 385 insertions, 1 deletions
diff --git a/kde-frameworks/kio/Manifest b/kde-frameworks/kio/Manifest index 84c8c84b9d0d..354fb1d75f0e 100644 --- a/kde-frameworks/kio/Manifest +++ b/kde-frameworks/kio/Manifest @@ -1,6 +1,8 @@ AUX kio-5.70.0-fix-run-in-terminal.patch 4162 BLAKE2B 5fb81c0bce45dc22a8dea27b81e962e267f000aa224fa7ce2dfbf3dd01bb9cd90a73623482a1580a1b95de91e3d40a157988dc3123b3e1a942827ded77174588 SHA512 64b068ea2bc9eca10f8144bcace49989c75ab64d4991b12d4720421464e3c372c5a95d56d510f68d84424e4071e2b2ec9bc447fc30e5e3c9189ccd6156d56738 +AUX kio-5.74.1-handle-shell-scripts-consistenty.patch 13311 BLAKE2B a579f98dd358748654a9f3627eaea9d85f706d4f741a8ab7142d2f2b2a2acdb1ee1eb7c4dbdc34dd0edf2eb879f60bdd8edd7791c7fab1f001a9a5e49da54d58 SHA512 76caaadaa4ce1d3cf2d5a9418c70f44769445185f0752ae0aa00acf77ac7a215bc3f95fac860a90c7e6e6739d82c9250901dde1bad97ebb01b0ba51ed1a37f3e +AUX kio-5.74.1-kio_trash-too-strict-perms-check.patch 2982 BLAKE2B 4ce5f193979a99755f1d5bcb454ab50a6c90e922ce40966dda8dd43765646a42bf6cefe8b237af69a07b5e20b45f92d092818ca6ce19148f3cb0d0855cb5b59f SHA512 21c8b31080bea94343a5618af780e50b09ff0477f563941955bae94ac8eb676312dd1b63b4a5b2f19b37317652996147614b22e47a17eb7c0f3beeff38ee6f70 DIST kio-5.70.1.tar.xz 3200752 BLAKE2B cc56ee412cb647c8921a36c3e47747640d5574444630f70887401c69ca1a367205adf4d7cd45b721abd103efcb1265c956654fce2dfc5b3fe6241413c51f1b88 SHA512 12287f330e8e7b9ac9c0ff24c1f8f980fbd338ce3f341d8005d6dc6e3acdf96da07adeea693b3361909819d8814192503e8d2c93ca9b9958d985f0d09f202661 DIST kio-5.74.1.tar.xz 3281248 BLAKE2B 584fde1483477b70ee7892bf0de37aedb62672c2ada57d85c9646894606f10b6a03750030e1926441707b12b18ece167fa3a0dbbb75a8155bddfd35342d372f8 SHA512 a563b939d2bc71443c6c748ddf293fab84072efebdcea639707d7aaf2739356a906668be3dca915464ce7c81b63d7482ac024df786e04bbafcf999cde5ebc5e2 EBUILD kio-5.70.1-r1.ebuild 2458 BLAKE2B cd466f2258c565420ff6e34a42a0ea1ea85aa9f4e32fee0b9833e696994576de4feebda2001bab8d5b6f0b19b8bb4c6e53d3a716d21f516579836e83547d1c1c SHA512 d4ec508f1ec53a12d2d994cf6a02186fbccf3f44f5cd0897844c21af19ec136e0d50a73381a32c55418de334f6f7b21d0939977ef49763582147617fec3c00ad -EBUILD kio-5.74.1.ebuild 2395 BLAKE2B 34e8488cf9edd0371b618757ca46a363040fc3766af3a82c833acb0a1e048001d9f8b0962f53857351258ae8706c6285639cbd0f0966ae323cc8c5674241e932 SHA512 8cadbd0d04604844750d670a7316aaf1da657e828a17ee46089b304dd1ec4ba30a3ead2e1bb7fc2922f68b40cd8c3254a71c0c3631bfe18c18a893ca84a12503 +EBUILD kio-5.74.1-r1.ebuild 2526 BLAKE2B 1e91b7dc1a3fdc9c94e569644fef4f0ec1849aa2c7bdd78d80290227661d05e8276e71daea274124dd894ca79719515d774f5db0f997de2d3e7f497cbcd55ccb SHA512 8167ad0e258a656ffd9712270225f9bd06420eee499f563e1f2e4184b6bf0bfa53ac117b7d098025d06db3bd21632f88afc121d64f91133c979a76c6557dd5a8 MISC metadata.xml 465 BLAKE2B f419d817ff7a98c06ebb921974d1c68f1c50eef4548f1d7bb819fb907b7379ad4d4b4424b598f9f216dc96f00a4e9acf7f051cc628af067954b13c3cb80ddada SHA512 6fae28d51cefecbf80962e976366b86ef54ac666421477787b8a438ae18101ea936865db76464b6a95e8ec6559138a063b269b1a17ff1687c73bb6ad398d4f89 diff --git a/kde-frameworks/kio/files/kio-5.74.1-handle-shell-scripts-consistenty.patch b/kde-frameworks/kio/files/kio-5.74.1-handle-shell-scripts-consistenty.patch new file mode 100644 index 000000000000..f5e17f338fda --- /dev/null +++ b/kde-frameworks/kio/files/kio-5.74.1-handle-shell-scripts-consistenty.patch @@ -0,0 +1,310 @@ +From fdd7c47c85d5d6dbf21e05e7a0d6afcf383f1d24 Mon Sep 17 00:00:00 2001 +From: Ahmad Samir <a.samirh78@gmail.com> +Date: Tue, 15 Sep 2020 20:06:49 +0200 +Subject: [PATCH] OpenUrlJob: handle all text scripts consistently + +Previously we only handled application/x-shellscript, but there are other +scripts; a script is technically a file that inherits both text/plain and +application/x-executable, e.g. .sh, .csh, .py, perl scripts ...etc. Treat +all those mime types the way we handled shell scripts: + - if it's not a local url, or isn't executable we open it in the preferred + text editor + - if it's executable either show the OpenOrExecute dialog or execute + directly depending on how the job is configured + +The mimetype world is a confusing one: + - Executables, this includes .exe files (MS Windows); and "application/x-executable" + and "application/x-sharedlib", this depends on various parameters (e.g. + stripped executables are x-sharedlib, the same executable if not stripped + is x-executable...) + - Scripts: shell, python, perl... etc scripts, which are text files that + can be executed or opened as text. + +Adjust the unit test. + +BUG: 425829 +BUG: 425177 +FIXED-IN: 5.75 +--- + autotests/openurljobtest.cpp | 56 +++++++++++++++++++++++-------- + autotests/openurljobtest.h | 2 ++ + src/gui/openurljob.cpp | 65 ++++++++++++++++++++++-------------- + 3 files changed, 85 insertions(+), 38 deletions(-) + +diff --git a/autotests/openurljobtest.cpp b/autotests/openurljobtest.cpp +index 2f2ef8ad..ed2211a8 100644 +--- a/autotests/openurljobtest.cpp ++++ b/autotests/openurljobtest.cpp +@@ -103,14 +103,13 @@ void OpenUrlJobTest::initTestCase() + KConfigGroup grp = mimeAppsCfg.group("Default Applications"); + grp.writeEntry("text/plain", s_tempServiceName); + grp.writeEntry("text/html", s_tempServiceName); +- grp.writeEntry("application/x-shellscript", s_tempServiceName); + grp.sync(); + +- for (const char *mimeType : {"text/plain", "application/x-shellscript"}) { +- KService::Ptr preferredTextEditor = KApplicationTrader::preferredService(QString::fromLatin1(mimeType)); +- QVERIFY(preferredTextEditor); +- QCOMPARE(preferredTextEditor->entryPath(), m_fakeService); +- } ++ ++ // "text/plain" encompasses all scripts (shell, python, perl) ++ KService::Ptr preferredTextEditor = KApplicationTrader::preferredService(QStringLiteral("text/plain")); ++ QVERIFY(preferredTextEditor); ++ QCOMPARE(preferredTextEditor->entryPath(), m_fakeService); + + // As used for preferredService + QVERIFY(KService::serviceByDesktopName("openurljobtest_service")); +@@ -230,17 +229,38 @@ void OpenUrlJobTest::invalidUrl() + QCOMPARE(job2->errorString(), QStringLiteral("Malformed URL\n/pathonly")); + } + ++void OpenUrlJobTest::refuseRunningNativeExecutables_data() ++{ ++ QTest::addColumn<QString>("mimeType"); ++ ++ // Executables under e.g. /usr/bin/ can be either of these two mimetypes ++ // see https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/11 ++ QTest::newRow("x-sharedlib") << "application/x-sharedlib"; ++ QTest::newRow("x-executable") << "application/x-executable"; ++} ++ + void OpenUrlJobTest::refuseRunningNativeExecutables() + { +- KIO::OpenUrlJob *job = new KIO::OpenUrlJob(QUrl::fromLocalFile(QCoreApplication::applicationFilePath()), QStringLiteral("application/x-executable"), this); ++ QFETCH(QString, mimeType); ++ ++ KIO::OpenUrlJob *job = new KIO::OpenUrlJob(QUrl::fromLocalFile(QCoreApplication::applicationFilePath()), mimeType, this); + QVERIFY(!job->exec()); + QCOMPARE(job->error(), KJob::UserDefinedError); + QVERIFY2(job->errorString().contains("For security reasons, launching executables is not allowed in this context."), qPrintable(job->errorString())); + } + ++void OpenUrlJobTest::refuseRunningRemoteNativeExecutables_data() ++{ ++ QTest::addColumn<QString>("mimeType"); ++ QTest::newRow("x-sharedlib") << "application/x-sharedlib"; ++ QTest::newRow("x-executable") << "application/x-executable"; ++} ++ + void OpenUrlJobTest::refuseRunningRemoteNativeExecutables() + { +- KIO::OpenUrlJob *job = new KIO::OpenUrlJob(QUrl("protocol://host/path/exe"), QStringLiteral("application/x-executable"), this); ++ QFETCH(QString, mimeType); ++ ++ KIO::OpenUrlJob *job = new KIO::OpenUrlJob(QUrl("protocol://host/path/exe"), mimeType, this); + job->setRunExecutables(true); // even with this enabled, an error will occur + QVERIFY(!job->exec()); + QCOMPARE(job->error(), KJob::UserDefinedError); +@@ -273,8 +293,11 @@ void OpenUrlJobTest::runScript_data() + { + QTest::addColumn<QString>("mimeType"); + ++ // All text-based scripts inherit text/plain and application/x-executable, no need to test ++ // all flavours (python, perl, lua, awk ...etc), this sample should be enough + QTest::newRow("shellscript") << "application/x-shellscript"; +- QTest::newRow("native") << "application/x-executable"; ++ QTest::newRow("pythonscript") << "text/x-python"; ++ QTest::newRow("javascript") << "application/javascript"; + } + + void OpenUrlJobTest::runScript() +@@ -305,16 +328,23 @@ void OpenUrlJobTest::runScript() + + void OpenUrlJobTest::runNativeExecutable_data() + { ++ QTest::addColumn<QString>("mimeType"); + QTest::addColumn<bool>("withHandler"); + QTest::addColumn<bool>("handlerRetVal"); + +- QTest::newRow("no_handler") << false << false; +- QTest::newRow("handler_false") << true << false; +- QTest::newRow("handler_true") << true << true; ++ QTest::newRow("no_handler_x-sharedlib") << "application/x-sharedlib" << false << false; ++ QTest::newRow("handler_false_x-sharedlib") << "application/x-sharedlib" << true << false; ++ QTest::newRow("handler_true_x-sharedlib") << "application/x-sharedlib" << true << true; ++ ++ QTest::newRow("no_handler_x-executable") << "application/x-executable" << false << false; ++ QTest::newRow("handler_false_x-executable") << "application/x-executable" << true << false; ++ QTest::newRow("handler_true_x-executable") << "application/x-executable" << true << true; ++ + } + + void OpenUrlJobTest::runNativeExecutable() + { ++ QFETCH(QString, mimeType); + QFETCH(bool, withHandler); + QFETCH(bool, handlerRetVal); + +@@ -335,7 +365,7 @@ void OpenUrlJobTest::runNativeExecutable() + KIO::setDefaultUntrustedProgramHandler(withHandler ? &s_handler : nullptr); + + // When using OpenUrlJob to run the executable +- KIO::OpenUrlJob *job = new KIO::OpenUrlJob(QUrl::fromLocalFile(scriptFile), QStringLiteral("application/x-executable"), this); ++ KIO::OpenUrlJob *job = new KIO::OpenUrlJob(QUrl::fromLocalFile(scriptFile), mimeType, this); + job->setRunExecutables(true); // startProcess tests the case where this isn't set + const bool success = job->exec(); + +diff --git a/autotests/openurljobtest.h b/autotests/openurljobtest.h +index e71987d9..f5b9a5be 100644 +--- a/autotests/openurljobtest.h ++++ b/autotests/openurljobtest.h +@@ -26,7 +26,9 @@ private Q_SLOTS: + + void noServiceNoHandler(); + void invalidUrl(); ++ void refuseRunningNativeExecutables_data(); + void refuseRunningNativeExecutables(); ++ void refuseRunningRemoteNativeExecutables_data(); + void refuseRunningRemoteNativeExecutables(); + void notAuthorized(); + void runScript_data(); +diff --git a/src/gui/openurljob.cpp b/src/gui/openurljob.cpp +index 8ac187b4..3e35c95c 100644 +--- a/src/gui/openurljob.cpp ++++ b/src/gui/openurljob.cpp +@@ -73,9 +73,9 @@ public: + + private: + void executeCommand(); +- void handleExecutables(const QMimeType &mimeType); ++ void handleBinaries(const QMimeType &mimeType); + void handleDesktopFiles(); +- void handleShellscripts(); ++ void handleScripts(); + void openInPreferredApp(); + void runLink(const QString &filePath, const QString &urlStr, const QString &optionalServiceName); + +@@ -439,14 +439,29 @@ void KIO::OpenUrlJobPrivate::emitAccessDenied() + q->emitResult(); + } + +-// was: KRun::isExecutable (minus application/x-desktop and application/x-shellscript mimetypes). ++// was: KRun::isExecutable (minus application/x-desktop mimetype). + // Feel free to make public if needed. +-static bool isExecutableMime(const QMimeType &mimeType) ++static bool isBinary(const QMimeType &mimeType) + { +- return (mimeType.inherits(QStringLiteral("application/x-executable")) || +- /* e.g. /usr/bin/ls, see https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/11 */ +- mimeType.inherits(QStringLiteral("application/x-sharedlib")) || +- mimeType.inherits(QStringLiteral("application/x-ms-dos-executable"))); ++ // - Binaries could be e.g.: ++ // - application/x-executable ++ // - application/x-sharedlib e.g. /usr/bin/ls, see ++ // https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/11 ++ // ++ // - Mimetypes that inherit application/x-executable _and_ text/plain are scripts, these are ++ // handled by handleScripts() ++ ++ return (mimeType.inherits(QStringLiteral("application/x-executable")) ++ || mimeType.inherits(QStringLiteral("application/x-sharedlib")) ++ || mimeType.inherits(QStringLiteral("application/x-ms-dos-executable"))); ++} ++ ++// Helper function that returns whether a file is a text-based script ++// e.g. ".sh", ".csh", ".py", ".js" ++static bool isTextScript(const QMimeType &mimeType) ++{ ++ return (mimeType.inherits(QStringLiteral("application/x-executable")) ++ && mimeType.inherits(QStringLiteral("text/plain"))); + } + + // Helper function that returns whether a file has the execute bit set or not. +@@ -456,7 +471,7 @@ static bool hasExecuteBit(const QString &fileName) + } + + // Handle native binaries (.e.g. /usr/bin/*); and .exe files +-void KIO::OpenUrlJobPrivate::handleExecutables(const QMimeType &mimeType) ++void KIO::OpenUrlJobPrivate::handleBinaries(const QMimeType &mimeType) + { + if (!KAuthorized::authorize(QStringLiteral("shell_access"))) { + emitAccessDenied(); +@@ -475,11 +490,9 @@ void KIO::OpenUrlJobPrivate::handleExecutables(const QMimeType &mimeType) + + const QString localPath = m_url.toLocalFile(); + +- // Check whether file is an executable script +-#ifdef Q_OS_WIN +- const bool isNativeBinary = !mimeType.inherits(QStringLiteral("text/plain")); +-#else +- const bool isNativeBinary = !mimeType.inherits(QStringLiteral("text/plain")) && !mimeType.inherits(QStringLiteral("application/x-ms-dos-executable")); ++ bool isNativeBinary = true; ++#ifndef Q_OS_WIN ++ isNativeBinary = !mimeType.inherits(QStringLiteral("application/x-ms-dos-executable")); + #endif + + if (m_showOpenOrExecuteDialog) { +@@ -497,6 +510,8 @@ void KIO::OpenUrlJobPrivate::handleExecutables(const QMimeType &mimeType) + } + }; + ++ // Ask the user for confirmation before executing this binary (for binaries ++ // the dialog will only show Execute/Cancel) + showOpenOrExecuteFileDialog(dialogFinished); + return; + } +@@ -601,15 +616,15 @@ void KIO::OpenUrlJobPrivate::runUrlWithMimeType() + return; + } + +- // Shell scripts +- if (mimeType.inherits(QStringLiteral("application/x-shellscript"))) { +- handleShellscripts(); ++ // Scripts (e.g. .sh, .csh, .py, .js) ++ if (isTextScript(mimeType)) { ++ handleScripts(); + return; + } + +- // Binaries (e.g. /usr/bin/konsole) and .exe files +- if (isExecutableMime(mimeType)) { +- handleExecutables(mimeType); ++ // Binaries (e.g. /usr/bin/{konsole,ls}) and .exe files ++ if (isBinary(mimeType)) { ++ handleBinaries(mimeType); + return; + } + +@@ -677,8 +692,9 @@ void KIO::OpenUrlJobPrivate::handleDesktopFiles() + openInPreferredApp(); + } + +-void KIO::OpenUrlJobPrivate::handleShellscripts() ++void KIO::OpenUrlJobPrivate::handleScripts() + { ++ // Executable scripts of any type can run arbitrary shell commands + if (!KAuthorized::authorize(QStringLiteral("shell_access"))) { + emitAccessDenied(); + return; +@@ -687,8 +703,7 @@ void KIO::OpenUrlJobPrivate::handleShellscripts() + const bool isLocal = m_url.isLocalFile(); + const QString localPath = m_url.toLocalFile(); + if (!isLocal || !hasExecuteBit(localPath)) { +- // Open remote shell scripts or ones without the execute bit, with the +- // default application ++ // Open remote scripts or ones without the execute bit, with the default application + openInPreferredApp(); + return; + } +@@ -706,7 +721,7 @@ void KIO::OpenUrlJobPrivate::handleShellscripts() + return; + } + +- if (m_runExecutables) { // Local executable shell script, proceed ++ if (m_runExecutables) { // Local executable script, proceed + executeCommand(); + } else { // Open in the default (text editor) app + openInPreferredApp(); +@@ -767,7 +782,7 @@ void KIO::OpenUrlJobPrivate::showOpenOrExecuteFileDialog(std::function<void(bool + + if (!s_openOrExecuteFileHandler) { + // No way to ask the user whether to execute or open +- if (mimeType.inherits(QStringLiteral("application/x-shellscript")) ++ if (isTextScript(mimeType) + || mimeType.inherits(QStringLiteral("application/x-desktop"))) { // Open text-based ones in the default app + openInPreferredApp(); + } else { +-- +GitLab + diff --git a/kde-frameworks/kio/files/kio-5.74.1-kio_trash-too-strict-perms-check.patch b/kde-frameworks/kio/files/kio-5.74.1-kio_trash-too-strict-perms-check.patch new file mode 100644 index 000000000000..d0b0ca0769cc --- /dev/null +++ b/kde-frameworks/kio/files/kio-5.74.1-kio_trash-too-strict-perms-check.patch @@ -0,0 +1,67 @@ +From 03bcb3d3ff89074a68839b6ebeb8030ef0ee4fd1 Mon Sep 17 00:00:00 2001 +From: David Faure <faure@kde.org> +Date: Fri, 11 Sep 2020 11:54:09 +0200 +Subject: [PATCH] kio_trash: remove unnecessarily strict permission check + +Tested with `chmod 0770 /d/.Trash-1000` (where /d is a mount point), +kio_trash complained about security checks before this commit, +and works with it. + +Also tested with a USB key which ends up mounted as +type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=100,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2). After kio_trash creates .Trash-1000 +it complained about a "strange filesystem", and while this is still true :), +the removal of the code in TrashImpl::initTrashDirectory makes +the trash dir on the USB key usable. + +BUG: 76380 +FIXED-IN: 5.74 +--- + src/ioslaves/trash/trashimpl.cpp | 25 ++++--------------------- + 1 file changed, 4 insertions(+), 21 deletions(-) + +diff --git a/src/ioslaves/trash/trashimpl.cpp b/src/ioslaves/trash/trashimpl.cpp +index b1ba87a4..9ec7cc7a 100644 +--- a/src/ioslaves/trash/trashimpl.cpp ++++ b/src/ioslaves/trash/trashimpl.cpp +@@ -1210,9 +1210,9 @@ QString TrashImpl::trashForMountPoint(const QString &topdir, bool createIfNeeded + const QByteArray trashDir_c = QFile::encodeName(trashDir); + if (QT_LSTAT(trashDir_c.constData(), &buff) == 0) { + if ((buff.st_uid == uid) // must be owned by user +- && (S_ISDIR(buff.st_mode)) // must be a dir +- && (!S_ISLNK(buff.st_mode)) // not a symlink +- && ((buff.st_mode & 0777) == 0700)) { // rwx for user, ------ for group and others ++ && S_ISDIR(buff.st_mode) // must be a dir ++ && !S_ISLNK(buff.st_mode) // not a symlink ++ && ((buff.st_mode & 0700) == 0700)) { // and we need write access to it + + if (checkTrashSubdirs(trashDir_c)) { + return trashDir; +@@ -1248,24 +1248,7 @@ bool TrashImpl::initTrashDirectory(const QByteArray &trashDir_c) const + return false; + } + //qCDebug(KIO_TRASH); +- // This trash dir will be useable only if the directory is owned by user. +- // In theory this is the case, but not on e.g. USB keys... +- uid_t uid = getuid(); +- QT_STATBUF buff; +- if (QT_LSTAT(trashDir_c.constData(), &buff) != 0) { +- return false; // huh? +- } +- if ((buff.st_uid == uid) // must be owned by user +- && ((buff.st_mode & 0777) == 0700)) { // rwx for user, --- for group and others +- +- return checkTrashSubdirs(trashDir_c); +- +- } else { +- qCWarning(KIO_TRASH) << trashDir_c << "just created, by it doesn't have the right permissions, probably some strange unsupported filesystem"; +- ::rmdir(trashDir_c.constData()); +- return false; +- } +- return true; ++ return checkTrashSubdirs(trashDir_c); + } + + bool TrashImpl::checkTrashSubdirs(const QByteArray &trashDir_c) const +-- +GitLab + diff --git a/kde-frameworks/kio/kio-5.74.1.ebuild b/kde-frameworks/kio/kio-5.74.1-r1.ebuild index b2b55fc7759f..b77cae090c8c 100644 --- a/kde-frameworks/kio/kio-5.74.1.ebuild +++ b/kde-frameworks/kio/kio-5.74.1-r1.ebuild @@ -71,6 +71,11 @@ PDEPEND=" # tests hang RESTRICT+=" test" +PATCHES=( + "${FILESDIR}"/${P}-kio_trash-too-strict-perms-check.patch + "${FILESDIR}"/${P}-handle-shell-scripts-consistenty.patch +) + src_configure() { local mycmakeargs=( $(cmake_use_find_package acl ACL) |