diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-01-16 18:06:18 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-01-18 17:31:36 +0100 |
commit | 99a2fd3bcaa123d38a2d757cb3693e31e138e56b (patch) | |
tree | 81b3c653c7ef582695092c6c2200dc129642a32a /src | |
parent | cda7faa9a5ae2fa1ebc27b08e84d5ce62e46e37b (diff) | |
download | systemd-99a2fd3bcaa123d38a2d757cb3693e31e138e56b.tar.gz |
main: when generating the resource limit to pass to children, take FD_SETSIZE into consideration
When we synthesize a "struct rlimit" structure to pass on for
RLIMIT_NOFILE to our children, let's explicitly make sure that the soft
limit is not above FD_SETSIZE, for compat reason with select().
Note this only applies when we derive the "struct rlimit" from what we
inherited. If the user configures something explicitly it always takes
precedence.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/main.c b/src/core/main.c index 1b81542e8c..561f956f0a 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1304,6 +1304,11 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) { if (arg_system) rl->rlim_max = MIN((rlim_t) nr, MAX(rl->rlim_max, (rlim_t) HIGH_RLIMIT_NOFILE)); + /* If for some reason we were invoked with a soft limit above 1024 (which should never + * happen!, but who knows what we get passed in from pam_limit when invoked as --user + * instance), then lower what we pass on to not confuse our children */ + rl->rlim_cur = MIN(rl->rlim_cur, (rlim_t) FD_SETSIZE); + arg_default_rlimit[RLIMIT_NOFILE] = rl; } |