From: William Earley Date: Sun, 27 Sep 2020 11:24:30 +0000 (+0100) Subject: sysdeps: Don't raise RLIMIT_NOFILE beyond OPEN_MAX on macOS X-Git-Tag: dbus-1.12.22~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dc84fd22b0134785bb5258df4e40456cfc12811;p=thirdparty%2Fdbus.git sysdeps: Don't raise RLIMIT_NOFILE beyond OPEN_MAX on macOS dbus-daemon fails to launch on macOS 10.5 and above because of a breaking change in setrlimit, in which RLIM_INFINITY is no longer supported for RLIMIT_NOFILE. Instead we must use OPEN_MAX. Resolves: #309 (cherry picked from commit 691946dabcdd3e97787655d977a4da33fe56d433) --- diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 26fcb5bc9..cc7bbe626 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -447,7 +447,14 @@ _dbus_rlimit_raise_fd_limit (DBusError *error) * and older and non-systemd Linux systems would typically set rlim_cur * to 1024 and rlim_max to 4096. */ if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max) - lim.rlim_cur = lim.rlim_max; + { +#if defined(__APPLE__) && defined(__MACH__) + /* macOS 10.5 and above no longer allows RLIM_INFINITY for rlim_cur */ + lim.rlim_cur = MIN (OPEN_MAX, lim.rlim_max); +#else + lim.rlim_cur = lim.rlim_max; +#endif + } /* Early-return if there is nothing to do. */ if (lim.rlim_max == old.rlim_max &&