commit:     ff8eb9b0e29b1949fc45e890e06767c8f656a4e0
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 17 16:19:04 2019 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Jun 17 16:19:04 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ff8eb9b0

sys-apps/systemd: avoid error setting fs.file-max on linux-5.2

Package-Manager: Portage-2.3.67_p9, Repoman-2.3.14_p4
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 sys-apps/systemd/files/242-file-max.patch          | 31 ++++++++++++++++++++++
 ...systemd-241-r1.ebuild => systemd-241-r2.ebuild} |  1 +
 ...systemd-242-r2.ebuild => systemd-242-r3.ebuild} |  1 +
 3 files changed, 33 insertions(+)

diff --git a/sys-apps/systemd/files/242-file-max.patch 
b/sys-apps/systemd/files/242-file-max.patch
new file mode 100644
index 00000000000..0a1fe950e29
--- /dev/null
+++ b/sys-apps/systemd/files/242-file-max.patch
@@ -0,0 +1,31 @@
+From 6e2f78948403a4cce45b9e34311c9577c624f066 Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lenn...@poettering.net>
+Date: Mon, 17 Jun 2019 10:51:25 +0200
+Subject: [PATCH] core: set fs.file-max sysctl to LONG_MAX rather than
+ ULONG_MAX
+
+Since kernel 5.2 the kernel thankfully returns proper errors when we
+write a value out of range to the sysctl. Which however breaks writing
+ULONG_MAX to request the maximum value. Hence let's write the new
+maximum value instead, LONG_MAX.
+---
+ src/core/main.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/core/main.c b/src/core/main.c
+index b33ea1b5b52..e7f51815f07 100644
+--- a/src/core/main.c
++++ b/src/core/main.c
+@@ -1245,9 +1245,9 @@ static void bump_file_max_and_nr_open(void) {
+ #endif
+ 
+ #if BUMP_PROC_SYS_FS_FILE_MAX
+-        /* I so wanted to use STRINGIFY(ULONG_MAX) here, but alas we can't as 
glibc/gcc define that as
+-         * "(0x7fffffffffffffffL * 2UL + 1UL)". Seriously. 😢 */
+-        if (asprintf(&t, "%lu\n", ULONG_MAX) < 0) {
++        /* The maximum the kernel allows for this since 5.2 is LONG_MAX, use 
that. (Previously thing where
++         * different but the operation would fail silently.) */
++        if (asprintf(&t, "%li\n", LONG_MAX) < 0) {
+                 log_oom();
+                 return;
+         }

diff --git a/sys-apps/systemd/systemd-241-r1.ebuild 
b/sys-apps/systemd/systemd-241-r2.ebuild
similarity index 99%
rename from sys-apps/systemd/systemd-241-r1.ebuild
rename to sys-apps/systemd/systemd-241-r2.ebuild
index a6ba1136fd7..f1d8b6296e6 100644
--- a/sys-apps/systemd/systemd-241-r1.ebuild
+++ b/sys-apps/systemd/systemd-241-r2.ebuild
@@ -170,6 +170,7 @@ src_prepare() {
                
"${FILESDIR}"/CVE-2019-6454/0002-Allocate-temporary-strings-to-hold-dbus-paths-on-the.patch
                "${FILESDIR}"/241-version-dep.patch
                "${FILESDIR}"/242-gcc-9.patch
+               "${FILESDIR}"/242-file-max.patch
        )
 
        if ! use vanilla; then

diff --git a/sys-apps/systemd/systemd-242-r2.ebuild 
b/sys-apps/systemd/systemd-242-r3.ebuild
similarity index 99%
rename from sys-apps/systemd/systemd-242-r2.ebuild
rename to sys-apps/systemd/systemd-242-r3.ebuild
index c2b6ac9fb90..4af6fc44b6e 100644
--- a/sys-apps/systemd/systemd-242-r2.ebuild
+++ b/sys-apps/systemd/systemd-242-r3.ebuild
@@ -173,6 +173,7 @@ src_prepare() {
                "${FILESDIR}"/242-gcc-9.patch
                "${FILESDIR}"/242-socket-util-flush-accept.patch
                "${FILESDIR}"/242-wireguard-listenport.patch
+               "${FILESDIR}"/242-file-max.patch
        )
 
        if ! use vanilla; then

Reply via email to