1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

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.
This commit is contained in:
Lennart Poettering 2019-01-16 14:47:09 +01:00
parent f26ad32197
commit c0d7695908

View File

@ -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");