Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/systemd/files/, sys-apps/systemd/
Date: Thu, 09 May 2019 13:41:50
Message-Id: 1557409290.eb1d80e6a30d09f9f139877c5b754c8a8e918d7a.floppym@gentoo
1 commit: eb1d80e6a30d09f9f139877c5b754c8a8e918d7a
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 9 13:41:30 2019 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Thu May 9 13:41:30 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eb1d80e6
7
8 sys-apps/systemd: backport patch to fix dracut boot
9
10 Closes: https://bugs.gentoo.org/685002
11 Package-Manager: Portage-2.3.66_p2, Repoman-2.3.12_p111
12 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
13
14 .../files/242-socket-util-flush-accept.patch | 46 ++++++++++++++++++++++
15 .../{systemd-242.ebuild => systemd-242-r1.ebuild} | 1 +
16 2 files changed, 47 insertions(+)
17
18 diff --git a/sys-apps/systemd/files/242-socket-util-flush-accept.patch b/sys-apps/systemd/files/242-socket-util-flush-accept.patch
19 new file mode 100644
20 index 00000000000..4849c4c0789
21 --- /dev/null
22 +++ b/sys-apps/systemd/files/242-socket-util-flush-accept.patch
23 @@ -0,0 +1,46 @@
24 +From f3d75364fbebf2ddb6393e54db5e10b6f6234e14 Mon Sep 17 00:00:00 2001
25 +From: Lennart Poettering <lennart@××××××××××.net>
26 +Date: Thu, 18 Apr 2019 15:13:54 +0200
27 +Subject: [PATCH] socket-util: make sure flush_accept() doesn't hang on
28 + unexpected EOPNOTSUPP
29 +
30 +So apparently there are two reasons why accept() can return EOPNOTSUPP:
31 +because the socket is not a listening stream socket (or similar), or
32 +because the incoming TCP connection for some reason wasn't acceptable to
33 +the host. THe latter should be a transient error, as suggested on
34 +accept(2). The former however should be considered fatal for
35 +flush_accept(). Let's fix this by explicitly checking whether the socket
36 +is a listening socket beforehand.
37 +---
38 + src/basic/socket-util.c | 17 +++++++++++++++--
39 + 1 file changed, 15 insertions(+), 2 deletions(-)
40 +
41 +diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
42 +index 904bafb76f9..e787d53d8f4 100644
43 +--- a/src/basic/socket-util.c
44 ++++ b/src/basic/socket-util.c
45 +@@ -1225,9 +1225,22 @@ int flush_accept(int fd) {
46 + .fd = fd,
47 + .events = POLLIN,
48 + };
49 +- int r;
50 ++ int r, b;
51 ++ socklen_t l = sizeof(b);
52 ++
53 ++ /* Similar to flush_fd() but flushes all incoming connection by accepting them and immediately
54 ++ * closing them. */
55 ++
56 ++ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &b, &l) < 0)
57 ++ return -errno;
58 +
59 +- /* Similar to flush_fd() but flushes all incoming connection by accepting them and immediately closing them. */
60 ++ assert(l == sizeof(b));
61 ++ if (!b) /* Let's check if this is a socket accepting connections before calling accept(). That's
62 ++ * because accept4() can return EOPNOTSUPP in the fd we are called on is not a listening
63 ++ * socket, or in case the incoming TCP connection transiently triggered that (see accept(2)
64 ++ * man page for details). The latter case is a transient error we should continue looping
65 ++ * on. The former case however is fatal. */
66 ++ return -ENOTTY;
67 +
68 + for (;;) {
69 + int cfd;
70
71 diff --git a/sys-apps/systemd/systemd-242.ebuild b/sys-apps/systemd/systemd-242-r1.ebuild
72 similarity index 99%
73 rename from sys-apps/systemd/systemd-242.ebuild
74 rename to sys-apps/systemd/systemd-242-r1.ebuild
75 index d09494587fc..a2626727385 100644
76 --- a/sys-apps/systemd/systemd-242.ebuild
77 +++ b/sys-apps/systemd/systemd-242-r1.ebuild
78 @@ -171,6 +171,7 @@ src_prepare() {
79 # Add local patches here
80 PATCHES+=(
81 "${FILESDIR}"/242-gcc-9.patch
82 + "${FILESDIR}"/242-socket-util-flush-accept.patch
83 )
84
85 if ! use vanilla; then