diff options
author | 2018-11-26 16:06:26 +0100 | |
---|---|---|
committer | 2018-12-01 12:50:45 +0100 | |
commit | 595225af7a4f663788d26b8720e994fed71f9410 (patch) | |
tree | ca656b1aaa5655b0697472e7165272db02bc8a22 /src/journal-remote | |
parent | process-util: add new FORK_RLIMIT_NOFILE_SAFE flag for safe_fork() (diff) | |
download | systemd-595225af7a4f663788d26b8720e994fed71f9410.tar.gz systemd-595225af7a4f663788d26b8720e994fed71f9410.tar.bz2 systemd-595225af7a4f663788d26b8720e994fed71f9410.zip |
tree-wide: invoke rlimit_nofile_safe() before various exec{v,ve,l}() invocations
Whenever we invoke external, foreign code from code that has
RLIMIT_NOFILE's soft limit bumped to high values, revert it to 1024
first. This is a safety precaution for compatibility with programs using
select() which cannot operate with fds > 1024.
This commit adds the call to rlimit_nofile_safe() to all invocations of
exec{v,ve,l}() and friends that either are in code that we know runs
with RLIMIT_NOFILE bumped up (which is PID 1 and all journal code for
starters) or that is part of shared code that might end up there.
The calls are placed as early as we can in processes invoking a flavour
of execve(), but after the last time we do fd manipulations, so that we
can still take benefit of the high fd limits for that.
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-remote-main.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index c46e0acdd..b82d4b4a1 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -81,6 +81,8 @@ static int spawn_child(const char* child, char** argv) { _exit(EXIT_FAILURE); } + (void) rlimit_nofile_safe(); + execvp(child, argv); log_error_errno(errno, "Failed to exec child %s: %m", child); _exit(EXIT_FAILURE); |