From: Lennart Poettering Date: Wed, 16 Jan 2019 13:47:09 +0000 (+0100) Subject: main: when bumping RLIMIT_MEMLOCK, save the previous value to pass to children X-Git-Tag: v241-rc1~23^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0d76959080e3ba6534bce1c7053c750668e8b55;p=thirdparty%2Fsystemd.git main: when bumping RLIMIT_MEMLOCK, save the previous value to pass to children Let's make sure that the bumping of RLIMIT_MEMLOCK does not leak into our children. --- diff --git a/src/core/main.c b/src/core/main.c index d0d589e26ac..79f12c9209e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1327,6 +1327,17 @@ static int bump_rlimit_memlock(struct rlimit *saved_rlimit) { if (getrlimit(RLIMIT_MEMLOCK, saved_rlimit) < 0) return log_warning_errno(errno, "Reading RLIMIT_MEMLOCK failed, ignoring: %m"); + /* Pass the original value down to invoked processes */ + if (!arg_default_rlimit[RLIMIT_MEMLOCK]) { + struct rlimit *rl; + + rl = newdup(struct rlimit, saved_rlimit, 1); + if (!rl) + return log_oom(); + + arg_default_rlimit[RLIMIT_MEMLOCK] = rl; + } + r = setrlimit_closest(RLIMIT_MEMLOCK, &RLIMIT_MAKE_CONST(HIGH_RLIMIT_MEMLOCK)); if (r < 0) return log_warning_errno(r, "Setting RLIMIT_MEMLOCK failed, ignoring: %m");