Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | From 6e2f78948403a4cce45b9e34311c9577c624f066 Mon Sep 17 00:00:00 2001 |
| 2 | From: Lennart Poettering <lennart@poettering.net> |
| 3 | Date: Mon, 17 Jun 2019 10:51:25 +0200 |
| 4 | Subject: [PATCH] core: set fs.file-max sysctl to LONG_MAX rather than |
| 5 | ULONG_MAX |
| 6 | |
| 7 | Since kernel 5.2 the kernel thankfully returns proper errors when we |
| 8 | write a value out of range to the sysctl. Which however breaks writing |
| 9 | ULONG_MAX to request the maximum value. Hence let's write the new |
| 10 | maximum value instead, LONG_MAX. |
| 11 | |
| 12 | /cc @brauner |
| 13 | |
| 14 | Fixes: #12803 |
| 15 | |
| 16 | Upstream-Status: Backport |
| 17 | |
| 18 | Signed-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 | |
| 23 | diff --git a/src/core/main.c b/src/core/main.c |
| 24 | index 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 | } |