]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: set fs.file-max sysctl to LONG_MAX rather than ULONG_MAX
authorLennart Poettering <lennart@poettering.net>
Mon, 17 Jun 2019 08:51:25 +0000 (10:51 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 17 Jun 2019 13:48:11 +0000 (15:48 +0200)
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.

/cc @brauner

Fixes: #12803
src/core/main.c

index b33ea1b5b5286335ac04de7c6f2178ab1a74e303..e7f51815f07c39aeb7c992f73c8789dad25515f3 100644 (file)
@@ -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;
         }