blob: ff64f58c9cc6cf50387864a1cc88c550e47034b0 [file] [log] [blame]
Brad Bishop96ff1982019-08-19 13:50:42 -04001From 6e2f78948403a4cce45b9e34311c9577c624f066 Mon Sep 17 00:00:00 2001
2From: Lennart Poettering <lennart@poettering.net>
3Date: Mon, 17 Jun 2019 10:51:25 +0200
4Subject: [PATCH] core: set fs.file-max sysctl to LONG_MAX rather than
5 ULONG_MAX
6
7Since kernel 5.2 the kernel thankfully returns proper errors when we
8write a value out of range to the sysctl. Which however breaks writing
9ULONG_MAX to request the maximum value. Hence let's write the new
10maximum value instead, LONG_MAX.
11
12/cc @brauner
13
14Fixes: #12803
15
16Upstream-Status: Backport
17
18Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
19---
20 src/core/main.c | 6 +++---
21 1 file changed, 3 insertions(+), 3 deletions(-)
22
23diff --git a/src/core/main.c b/src/core/main.c
24index b33ea1b5b5..e7f51815f0 100644
25--- a/src/core/main.c
26+++ b/src/core/main.c
27@@ -1245,9 +1245,9 @@ static void bump_file_max_and_nr_open(void) {
28 #endif
29
30 #if BUMP_PROC_SYS_FS_FILE_MAX
31- /* I so wanted to use STRINGIFY(ULONG_MAX) here, but alas we can't as glibc/gcc define that as
32- * "(0x7fffffffffffffffL * 2UL + 1UL)". Seriously. 😢 */
33- if (asprintf(&t, "%lu\n", ULONG_MAX) < 0) {
34+ /* The maximum the kernel allows for this since 5.2 is LONG_MAX, use that. (Previously thing where
35+ * different but the operation would fail silently.) */
36+ if (asprintf(&t, "%li\n", LONG_MAX) < 0) {
37 log_oom();
38 return;
39 }