Accepting request 1032475 from GNOME:Next

- Add ca905744.patch: Revert "Handling collision between standard
  i/o file descriptors and newly created ones". The user-visible
  problem this solves is gnome-keyring-daemon eating 100% CPU.

OBS-URL: https://build.opensuse.org/request/show/1032475
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/glib2?expand=0&rev=495
This commit is contained in:
Bjørn Lie 2022-10-31 12:23:17 +00:00 committed by Git OBS Bridge
parent 2689d8304d
commit 2f0bb0abcb
3 changed files with 128 additions and 0 deletions

118
ca905744.patch Normal file
View File

@ -0,0 +1,118 @@
From ca905744dffb844663b5bd6b42f33e2d44f9b4cd Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 28 Oct 2022 11:21:04 -0400
Subject: [PATCH] Revert "Handling collision between standard i/o file
descriptors and newly created ones"
g_unix_open_pipe tries to avoid the standard io fd range
when getting pipe fds. This turns out to be a bad idea because
certain buggy programs rely on it using that range.
This reverts commit d9ba6150909818beb05573f54f26232063492c5b
and adds a test to ensure we don't inadvertently do it again later.
Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/2795
---
glib/glib-unix.c | 24 ------------------------
glib/tests/unix.c | 29 +++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/glib/glib-unix.c b/glib/glib-unix.c
index 4710c51168..bc152d7663 100644
--- a/glib/glib-unix.c
+++ b/glib/glib-unix.c
@@ -108,17 +108,6 @@ g_unix_open_pipe (int *fds,
ecode = pipe2 (fds, pipe2_flags);
if (ecode == -1 && errno != ENOSYS)
return g_unix_set_error_from_errno (error, errno);
- /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
- else if (fds[0] < 3 || fds[1] < 3)
- {
- int old_fds[2] = { fds[0], fds[1] };
- gboolean result = g_unix_open_pipe (fds, flags, error);
- close (old_fds[0]);
- close (old_fds[1]);
-
- if (!result)
- g_unix_set_error_from_errno (error, errno);
- }
else if (ecode == 0)
return TRUE;
/* Fall through on -ENOSYS, we must be running on an old kernel */
@@ -127,19 +116,6 @@ g_unix_open_pipe (int *fds,
ecode = pipe (fds);
if (ecode == -1)
return g_unix_set_error_from_errno (error, errno);
- /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
- else if (fds[0] < 3 || fds[1] < 3)
- {
- int old_fds[2] = { fds[0], fds[1] };
- gboolean result = g_unix_open_pipe (fds, flags, error);
- close (old_fds[0]);
- close (old_fds[1]);
-
- if (!result)
- g_unix_set_error_from_errno (error, errno);
-
- return result;
- }
if (flags == 0)
return TRUE;
diff --git a/glib/tests/unix.c b/glib/tests/unix.c
index 2112cab6bf..5dde2b52cc 100644
--- a/glib/tests/unix.c
+++ b/glib/tests/unix.c
@@ -26,6 +26,7 @@
#include "glib-unix.h"
#include <string.h>
#include <pwd.h>
+#include <unistd.h>
static void
test_pipe (void)
@@ -52,6 +53,33 @@ test_pipe (void)
g_assert (g_str_has_prefix (buf, "hello"));
}
+static void
+test_pipe_stdio_overwrite (void)
+{
+ GError *error = NULL;
+ int pipefd[2], ret;
+ gboolean res;
+ int stderr_fd;
+
+ stderr_fd = dup (STDERR_FILENO);
+ g_assert_cmpint (stderr_fd, >, 0);
+ close (STDERR_FILENO);
+
+ res = g_unix_open_pipe (pipefd, FD_CLOEXEC, &error);
+ g_assert (res);
+ g_assert_no_error (error);
+
+ g_assert_cmpint (pipefd[0], ==, STDERR_FILENO);
+
+ close (pipefd[0]);
+ close (pipefd[1]);
+
+ ret = dup2 (stderr_fd, STDERR_FILENO);
+ g_assert_cmpint (ret, >=, 0);
+
+ close (stderr_fd);
+}
+
static void
test_error (void)
{
@@ -337,6 +365,7 @@ main (int argc,
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/glib-unix/pipe", test_pipe);
+ g_test_add_func ("/glib-unix/pipe-stdio-overwrite", test_pipe_stdio_overwrite);
g_test_add_func ("/glib-unix/error", test_error);
g_test_add_func ("/glib-unix/nonblocking", test_nonblocking);
g_test_add_func ("/glib-unix/sighup", test_sighup);
--
GitLab

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Oct 31 12:18:51 UTC 2022 - Dominique Leuenberger <dimstar@opensuse.org>
- Add ca905744.patch: Revert "Handling collision between standard
i/o file descriptors and newly created ones". The user-visible
problem this solves is gnome-keyring-daemon eating 100% CPU.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Oct 26 12:07:15 UTC 2022 - Bjørn Lie <bjorn.lie@gmail.com> Wed Oct 26 12:07:15 UTC 2022 - Bjørn Lie <bjorn.lie@gmail.com>

View File

@ -58,6 +58,8 @@ Patch2: glib2-suppress-schema-deprecated-path-warning.patch
Patch3: glib2-dbus-socket-path.patch Patch3: glib2-dbus-socket-path.patch
# PATCH-FIX-OPENSUSE glib2-gdbus-codegen-version.patch olaf@aepfle.de -- Remove version string from files generated by gdbus-codegen # PATCH-FIX-OPENSUSE glib2-gdbus-codegen-version.patch olaf@aepfle.de -- Remove version string from files generated by gdbus-codegen
Patch4: glib2-gdbus-codegen-version.patch Patch4: glib2-gdbus-codegen-version.patch
# PATCH-FIX-UPSTREAM ca905744.patch dimstar@opensuse.org -- Revert "Handling collision between standard i/o file descriptors and newly created ones"
Patch5: https://gitlab.gnome.org/GNOME/glib/-/commit/ca905744.patch
BuildRequires: docbook-xsl-stylesheets BuildRequires: docbook-xsl-stylesheets
BuildRequires: fdupes BuildRequires: fdupes
@ -261,6 +263,7 @@ the functionality of the installed glib2 package.
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1 %patch4 -p1
%patch5 -p1
cp -a %{SOURCE1} %{SOURCE2} %{SOURCE5} . cp -a %{SOURCE1} %{SOURCE2} %{SOURCE5} .
cp -a %{SOURCE4} gnome_defaults.conf cp -a %{SOURCE4} gnome_defaults.conf
# replace /usr/bin/env shebangs # replace /usr/bin/env shebangs