Control: tags -1 + patch

Hi Sune!

On Fri, May 03, 2024 at 10:18:22AM +0200, Sune Stolborg Vuorela wrote:
> On Friday, May 3, 2024 10:06:27 AM CEST you wrote:
> > On Thu, May 02, 2024 at 04:37:30PM +0200, Sune Stolborg Vuorela wrote:
> > > […]
> > >
> > > If it works for you, I'll ask the debian kde maintainers to fix it.
> > >
> > It looks like it fixes the libreoffice issue (no modifications applied
> > to libreoffice).  With a patched kio package I was not able to
> > reproduce the issue.  Replacing just the kio binary package seems to
> > be sufficient.  We are going to test a bit more on other setups too.

Tested with libreoffice from bookworm-backports:  Fixed.

> The changes needed to libreoffice are already in Debian ( https://
> gerrit.libreoffice.org/c/core/+/162935 ) - also by Kevin Ottens who also
> authored this patch.

Great!

> […]
>
> For the ark issue, you need the two kio patches I referenced in the bug report
> - also patches by Kevin Ottens
> https://invent.kde.org/frameworks/kio/-/commit/3e6800b37
> https://invent.kde.org/frameworks/kio/-/commit/48322f443

Attached is the slightly modified patch (only context, to apply cleanly).

Best regards,

  Andi
>From d1a2dab1da43d613ae5a8459ddcb62c8d78c46ff Mon Sep 17 00:00:00 2001
From: Kevin Ottens <kevin.ott...@enioka.com>
Date: Fri, 5 Jan 2024 11:51:49 +0100
Subject: [PATCH] Don't leak file descriptors when spawning new workers

By default we inherit file descriptors from the parent in
the worker process. This is a leak of resources since the
worker won't be able to do anything with them. Also, in
the case of CIFS this causes locks which might lead to bad
surprises in the parent process.
---

Index: kio-5.103.0/src/kioslave/kioslave.cpp
===================================================================
--- kio-5.103.0.orig/src/kioslave/kioslave.cpp
+++ kio-5.103.0/src/kioslave/kioslave.cpp
@@ -18,6 +18,10 @@
 #include <QPluginLoader>
 #include <QString>
 
+#ifdef Q_OS_UNIX
+#include <sys/resource.h>
+#endif
+
 #ifdef Q_OS_WIN
 #include <QProcess>
 #include <QStandardPaths>
@@ -40,6 +44,17 @@ extern "C" KIO::AuthInfo *_kioslave_init
 
 int main(int argc, char **argv)
 {
+#ifdef Q_OS_UNIX
+    int max_fd = INT_MAX;
+    struct rlimit limit;
+    if (getrlimit(RLIMIT_NOFILE, &limit) == 0) {
+        max_fd = limit.rlim_cur;
+    }
+    for (int fd = STDERR_FILENO + 1; fd < max_fd; fd++) {
+        ::close(fd);
+    }
+#endif
+
     if (argc < 5) {
         fprintf(stderr, "Usage: kioslave5 <slave-lib> <protocol> <klauncher-socket> <app-socket>\n\nThis program is part of KDE.\n");
         return 1;

Reply via email to