Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/kio/, kde-frameworks/kio/files/
Date: Sat, 15 May 2021 10:49:37
Message-Id: 1621075762.aace2cf1177ab92d31ede9aeb02118d409baa700.asturm@gentoo
1 commit: aace2cf1177ab92d31ede9aeb02118d409baa700
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 15 10:46:06 2021 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Sat May 15 10:49:22 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aace2cf1
7
8 kde-frameworks/kio: Upstream backport request for memleak fix
9
10 See also: https://mail.kde.org/pipermail/distributions/2021-May/000998.html
11 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=398908
12 Package-Manager: Portage-3.0.18, Repoman-3.0.3
13 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
14
15 .../kio-5.82.0-MimeTypeFinderJob-memleak-1.patch | 69 +++++++++++++
16 .../kio-5.82.0-MimeTypeFinderJob-memleak-2.patch | 61 ++++++++++++
17 .../kio-5.82.0-MimeTypeFinderJob-memleak-3.patch | 52 ++++++++++
18 .../kio-5.82.0-MimeTypeFinderJob-memleak-4.patch | 62 ++++++++++++
19 kde-frameworks/kio/kio-5.82.0-r1.ebuild | 110 +++++++++++++++++++++
20 5 files changed, 354 insertions(+)
21
22 diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch
23 new file mode 100644
24 index 00000000000..08d72d754d7
25 --- /dev/null
26 +++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch
27 @@ -0,0 +1,69 @@
28 +From e79da836c34fce66231e396c7215314d0eba51b4 Mon Sep 17 00:00:00 2001
29 +From: Jonathan Marten <jjm@×××××××××××.uk>
30 +Date: Sat, 8 May 2021 15:20:39 +0000
31 +Subject: [PATCH] MimeTypeFinderJob: Resolve symlinks for a local file
32 +
33 +---
34 + autotests/mimetypefinderjobtest.cpp | 18 +++++++++++++++++-
35 + src/core/mimetypefinderjob.cpp | 2 +-
36 + 2 files changed, 18 insertions(+), 2 deletions(-)
37 +
38 +diff --git a/autotests/mimetypefinderjobtest.cpp b/autotests/mimetypefinderjobtest.cpp
39 +index 72296b9b8..f494ff3b6 100644
40 +--- a/autotests/mimetypefinderjobtest.cpp
41 ++++ b/autotests/mimetypefinderjobtest.cpp
42 +@@ -48,6 +48,7 @@ void MimeTypeFinderJobTest::determineMimeType_data()
43 + QTest::newRow("text_file_no_extension") << "text/plain" << "srcfile";
44 + QTest::newRow("desktop_file") << "application/x-desktop" << "foo.desktop";
45 + QTest::newRow("script") << "application/x-shellscript" << "srcfile.sh";
46 ++ QTest::newRow("directory") << "inode/directory" << "srcdir";
47 + /* clang-format on */
48 + }
49 +
50 +@@ -60,7 +61,12 @@ void MimeTypeFinderJobTest::determineMimeType()
51 + QTemporaryDir tempDir;
52 + const QString srcDir = tempDir.path();
53 + const QString srcFile = srcDir + QLatin1Char('/') + fileName;
54 +- createSrcFile(srcFile);
55 ++ if (mimeType == "inode/directory") {
56 ++ QVERIFY(QDir(srcDir).mkdir(fileName));
57 ++ } else {
58 ++ createSrcFile(srcFile);
59 ++ }
60 ++
61 + QVERIFY(QFile::exists(srcFile));
62 + const QUrl url = QUrl::fromLocalFile(srcFile);
63 +
64 +@@ -68,6 +74,16 @@ void MimeTypeFinderJobTest::determineMimeType()
65 + KIO::MimeTypeFinderJob *job = new KIO::MimeTypeFinderJob(url, this);
66 + QVERIFY2(job->exec(), qPrintable(job->errorString()));
67 + QCOMPARE(job->mimeType(), mimeType);
68 ++
69 ++ // Check that the result is the same when accessing the source
70 ++ // file through a symbolic link (bug #436708)
71 ++ const QString srcLink = srcDir + QLatin1String("/link_") + fileName;
72 ++ QVERIFY(QFile::link(srcFile, srcLink));
73 ++ const QUrl linkUrl = QUrl::fromLocalFile(srcLink);
74 ++
75 ++ job = new KIO::MimeTypeFinderJob(linkUrl, this);
76 ++ QVERIFY2(job->exec(), qPrintable(job->errorString()));
77 ++ QCOMPARE(job->mimeType(), mimeType);
78 + }
79 +
80 + void MimeTypeFinderJobTest::invalidUrl()
81 +diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
82 +index f5e50cdc4..48fc8c289 100644
83 +--- a/src/core/mimetypefinderjob.cpp
84 ++++ b/src/core/mimetypefinderjob.cpp
85 +@@ -122,7 +122,7 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
86 + {
87 + Q_ASSERT(m_mimeTypeName.isEmpty());
88 +
89 +- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic, KIO::HideProgressInfo);
90 ++ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
91 + if (!m_authPrompts) {
92 + job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
93 + }
94 +--
95 +GitLab
96 +
97
98 diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch
99 new file mode 100644
100 index 00000000000..bf3ff50802f
101 --- /dev/null
102 +++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch
103 @@ -0,0 +1,61 @@
104 +From c748d6987252fafc296cde9351b289ef734cf861 Mon Sep 17 00:00:00 2001
105 +From: Ahmad Samir <a.samirh78@×××××.com>
106 +Date: Thu, 13 May 2021 23:03:57 +0200
107 +Subject: [PATCH] kio_file: pass the absolute path to
108 + QMimeDatabase::mimeTypeForFile()
109 +
110 +Otherwise detecting the mime type based on the file content may fail and
111 +return application/octet-stream.
112 +
113 +And pass the whole url to createUDSEntry(), less QFile::decodeName/encodeName()
114 +in the middle is better and less error prone.
115 +
116 +Note that without this change a MimeTypeFinderJob could end up failing to
117 +find the mime type of a local file based on the file contents.
118 +---
119 + src/ioslaves/file/file_unix.cpp | 8 ++++----
120 + 1 file changed, 4 insertions(+), 4 deletions(-)
121 +
122 +diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp
123 +index 99d46c8f1..940e3cbc4 100644
124 +--- a/src/ioslaves/file/file_unix.cpp
125 ++++ b/src/ioslaves/file/file_unix.cpp
126 +@@ -364,7 +364,7 @@ inline static time_t stat_mtime(QT_STATBUF &buf)
127 + }
128 + #endif
129 +
130 +-static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details)
131 ++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QUrl &url)
132 + {
133 + assert(entry.count() == 0); // by contract :-)
134 + int entries = 0;
135 +@@ -539,7 +539,7 @@ static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSE
136 +
137 + if (details & KIO::StatMimeType) {
138 + QMimeDatabase db;
139 +- entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(filename).name());
140 ++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(url.toLocalFile()).name());
141 + }
142 +
143 + return true;
144 +@@ -1186,7 +1186,7 @@ void FileProtocol::listDir(const QUrl &url)
145 + listEntry(entry);
146 +
147 + } else {
148 +- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details)) {
149 ++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) {
150 + #if HAVE_SYS_XATTR_H
151 + if (isNtfsHidden(filename)) {
152 + bool ntfsHidden = true;
153 +@@ -1476,7 +1476,7 @@ void FileProtocol::stat(const QUrl &url)
154 + const KIO::StatDetails details = getStatDetails();
155 +
156 + UDSEntry entry;
157 +- if (!createUDSEntry(url.fileName(), _path, entry, details)) {
158 ++ if (!createUDSEntry(url.fileName(), _path, entry, details, url)) {
159 + error(KIO::ERR_DOES_NOT_EXIST, path);
160 + return;
161 + }
162 +--
163 +GitLab
164 +
165
166 diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch
167 new file mode 100644
168 index 00000000000..a9c55e1f7f2
169 --- /dev/null
170 +++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch
171 @@ -0,0 +1,52 @@
172 +From c19876052ecec18a87a82f5950e8909e22e895ba Mon Sep 17 00:00:00 2001
173 +From: Ahmad Samir <a.samirh78@×××××.com>
174 +Date: Thu, 13 May 2021 17:02:52 +0200
175 +Subject: [PATCH] MimeTypeFinderJob: the StatJob details should include the
176 + mimetype
177 +
178 +Apparently we forgot to specify that we want the UDS_MIME_TYPE field in
179 +the statFile() method (both when it lived in OpenUrlJob and when it was moved
180 +to MimeTypeFinderJob). And now there is a dedicated StatJob flag, StatMimeType,
181 +that we can use.
182 +
183 +Not passing KIO::StatMimeType when creating the StatJob meant the code always
184 +used a get job to determine the mime type, which mean that e.g. opening an
185 +ISO file from Dolphin, which supposedly just needs to launch Ark, had the
186 +whole file read into memory, which means that opening a couple of ISO's and
187 +you're out of memory...
188 +
189 +Thanks to sitter for doing a big chunk of the investigative work in the bug
190 +report.
191 +
192 +CCBUG: 398908
193 +---
194 + src/core/mimetypefinderjob.cpp | 6 +++++-
195 + 1 file changed, 5 insertions(+), 1 deletion(-)
196 +
197 +diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
198 +index 48fc8c289..baca58695 100644
199 +--- a/src/core/mimetypefinderjob.cpp
200 ++++ b/src/core/mimetypefinderjob.cpp
201 +@@ -122,7 +122,9 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
202 + {
203 + Q_ASSERT(m_mimeTypeName.isEmpty());
204 +
205 +- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
206 ++ static constexpr auto statFlags = KIO::StatBasic | KIO::StatResolveSymlink | KIO::StatMimeType;
207 ++
208 ++ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, statFlags, KIO::HideProgressInfo);
209 + if (!m_authPrompts) {
210 + job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
211 + }
212 +@@ -147,6 +149,8 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
213 +
214 + const KIO::UDSEntry entry = job->statResult();
215 +
216 ++ qCDebug(KIO_CORE) << "UDSEntry from StatJob in MimeTypeFinderJob" << entry;
217 ++
218 + const QString localPath = entry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH);
219 + if (!localPath.isEmpty()) {
220 + m_url = QUrl::fromLocalFile(localPath);
221 +--
222 +GitLab
223 +
224
225 diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch
226 new file mode 100644
227 index 00000000000..9e59a0eb16e
228 --- /dev/null
229 +++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch
230 @@ -0,0 +1,62 @@
231 +From 71484c97dee0c977a00f141123d8ccd9b93c2e96 Mon Sep 17 00:00:00 2001
232 +From: Ahmad Samir <a.samirh78@×××××.com>
233 +Date: Fri, 14 May 2021 21:19:31 +0200
234 +Subject: [PATCH] kio_file: fix how createUDSEntry() is called
235 +
236 +When calling createUDSEntry() from listDir(), we need to concatenate the full
237 +path to the item.
238 +
239 +This is an addendum to commit c748d6987252f.
240 +---
241 + src/ioslaves/file/file_unix.cpp | 14 ++++++++++----
242 + 1 file changed, 10 insertions(+), 4 deletions(-)
243 +
244 +diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp
245 +index 940e3cbc4..3573c200e 100644
246 +--- a/src/ioslaves/file/file_unix.cpp
247 ++++ b/src/ioslaves/file/file_unix.cpp
248 +@@ -364,7 +364,7 @@ inline static time_t stat_mtime(QT_STATBUF &buf)
249 + }
250 + #endif
251 +
252 +-static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QUrl &url)
253 ++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QString &fullPath)
254 + {
255 + assert(entry.count() == 0); // by contract :-)
256 + int entries = 0;
257 +@@ -539,7 +539,7 @@ static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSE
258 +
259 + if (details & KIO::StatMimeType) {
260 + QMimeDatabase db;
261 +- entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(url.toLocalFile()).name());
262 ++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(fullPath).name());
263 + }
264 +
265 + return true;
266 +@@ -1186,7 +1186,13 @@ void FileProtocol::listDir(const QUrl &url)
267 + listEntry(entry);
268 +
269 + } else {
270 +- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) {
271 ++ QString fullPath(path);
272 ++ if (!fullPath.endsWith(QLatin1Char('/'))) {
273 ++ fullPath += QLatin1Char('/');
274 ++ }
275 ++ fullPath += filename;
276 ++
277 ++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, fullPath)) {
278 + #if HAVE_SYS_XATTR_H
279 + if (isNtfsHidden(filename)) {
280 + bool ntfsHidden = true;
281 +@@ -1476,7 +1482,7 @@ void FileProtocol::stat(const QUrl &url)
282 + const KIO::StatDetails details = getStatDetails();
283 +
284 + UDSEntry entry;
285 +- if (!createUDSEntry(url.fileName(), _path, entry, details, url)) {
286 ++ if (!createUDSEntry(url.fileName(), _path, entry, details, path)) {
287 + error(KIO::ERR_DOES_NOT_EXIST, path);
288 + return;
289 + }
290 +--
291 +GitLab
292 +
293
294 diff --git a/kde-frameworks/kio/kio-5.82.0-r1.ebuild b/kde-frameworks/kio/kio-5.82.0-r1.ebuild
295 new file mode 100644
296 index 00000000000..297ae2bbe4a
297 --- /dev/null
298 +++ b/kde-frameworks/kio/kio-5.82.0-r1.ebuild
299 @@ -0,0 +1,110 @@
300 +# Copyright 1999-2021 Gentoo Authors
301 +# Distributed under the terms of the GNU General Public License v2
302 +
303 +EAPI=7
304 +
305 +ECM_DESIGNERPLUGIN="true"
306 +ECM_TEST="forceoptional"
307 +PVCUT=$(ver_cut 1-2)
308 +QTMIN=5.15.2
309 +VIRTUALX_REQUIRED="test"
310 +inherit ecm kde.org xdg-utils
311 +
312 +DESCRIPTION="Framework providing transparent file and data management"
313 +
314 +LICENSE="LGPL-2+"
315 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
316 +IUSE="acl +handbook kerberos +kwallet X"
317 +
318 +# tests hang
319 +RESTRICT+=" test"
320 +
321 +RDEPEND="
322 + dev-libs/libxml2
323 + dev-libs/libxslt
324 + >=dev-qt/qtdbus-${QTMIN}:5
325 + >=dev-qt/qtdeclarative-${QTMIN}:5
326 + >=dev-qt/qtgui-${QTMIN}:5
327 + >=dev-qt/qtnetwork-${QTMIN}:5[ssl]
328 + >=dev-qt/qtwidgets-${QTMIN}:5
329 + >=dev-qt/qtxml-${QTMIN}:5
330 + =kde-frameworks/kauth-${PVCUT}*:5
331 + =kde-frameworks/karchive-${PVCUT}*:5
332 + =kde-frameworks/kbookmarks-${PVCUT}*:5
333 + =kde-frameworks/kcodecs-${PVCUT}*:5
334 + =kde-frameworks/kcompletion-${PVCUT}*:5
335 + =kde-frameworks/kconfig-${PVCUT}*:5
336 + =kde-frameworks/kconfigwidgets-${PVCUT}*:5
337 + =kde-frameworks/kcoreaddons-${PVCUT}*:5
338 + =kde-frameworks/kcrash-${PVCUT}*:5
339 + =kde-frameworks/kdbusaddons-${PVCUT}*:5
340 + =kde-frameworks/kguiaddons-${PVCUT}*:5
341 + =kde-frameworks/ki18n-${PVCUT}*:5
342 + =kde-frameworks/kiconthemes-${PVCUT}*:5
343 + =kde-frameworks/kitemviews-${PVCUT}*:5
344 + =kde-frameworks/kjobwidgets-${PVCUT}*:5
345 + =kde-frameworks/knotifications-${PVCUT}*:5
346 + =kde-frameworks/kservice-${PVCUT}*:5
347 + =kde-frameworks/ktextwidgets-${PVCUT}*:5
348 + =kde-frameworks/kwidgetsaddons-${PVCUT}*:5
349 + =kde-frameworks/kwindowsystem-${PVCUT}*:5
350 + =kde-frameworks/kxmlgui-${PVCUT}*:5
351 + =kde-frameworks/solid-${PVCUT}*:5
352 + acl? (
353 + sys-apps/attr
354 + virtual/acl
355 + )
356 + handbook? ( =kde-frameworks/kdoctools-${PVCUT}*:5 )
357 + kerberos? ( virtual/krb5 )
358 + kwallet? ( =kde-frameworks/kwallet-${PVCUT}*:5 )
359 + X? ( >=dev-qt/qtx11extras-${QTMIN}:5 )
360 +"
361 +DEPEND="${RDEPEND}
362 + >=dev-qt/qtconcurrent-${QTMIN}:5
363 + test? ( sys-libs/zlib )
364 + X? (
365 + x11-base/xorg-proto
366 + x11-libs/libX11
367 + x11-libs/libXrender
368 + )
369 +"
370 +PDEPEND="
371 + >=kde-frameworks/kded-${PVCUT}:5
372 +"
373 +
374 +PATCHES=(
375 + # pending https://invent.kde.org/frameworks/kio/-/merge_requests/426
376 + "${FILESDIR}"/${PN}-5.81.0-fix-qtconcurrent-private-link.patch # bug 784971
377 + # upstream backport request - see also KDE-bug 398908
378 + "${FILESDIR}"/${P}-MimeTypeFinderJob-memleak-{1,2,3,4}.patch
379 + # git master/KIO 5.83:
380 + "${FILESDIR}"/${P}-no-useragent-kcm.patch
381 + "${FILESDIR}"/${P}-no-cache-kcm.patch
382 +)
383 +
384 +src_prepare() {
385 + ecm_src_prepare
386 + rm -rf po/*/docs/kcontrol5/{cache,useragent} || die # superfluous docs
387 +}
388 +
389 +src_configure() {
390 + local mycmakeargs=(
391 + $(cmake_use_find_package acl ACL)
392 + $(cmake_use_find_package handbook KF5DocTools)
393 + $(cmake_use_find_package kerberos GSSAPI)
394 + $(cmake_use_find_package kwallet KF5Wallet)
395 + $(cmake_use_find_package X X11)
396 + )
397 +
398 + ecm_src_configure
399 +}
400 +
401 +pkg_postinst() {
402 + ecm_pkg_postinst
403 + xdg_desktop_database_update
404 +}
405 +
406 +pkg_postrm() {
407 + ecm_pkg_postrm
408 + xdg_desktop_database_update
409 +}