summaryrefslogtreecommitdiffstats
path: root/src/import/pull-common.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-26 16:06:26 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-01 12:50:45 +0100
commit595225af7a4f663788d26b8720e994fed71f9410 (patch)
treeca656b1aaa5655b0697472e7165272db02bc8a22 /src/import/pull-common.c
parentprocess-util: add new FORK_RLIMIT_NOFILE_SAFE flag for safe_fork() (diff)
downloadsystemd-595225af7a4f663788d26b8720e994fed71f9410.tar.xz
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/import/pull-common.c')
-rw-r--r--src/import/pull-common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/import/pull-common.c b/src/import/pull-common.c
index a90693c802..acfe380969 100644
--- a/src/import/pull-common.c
+++ b/src/import/pull-common.c
@@ -14,6 +14,7 @@
#include "process-util.h"
#include "pull-common.h"
#include "pull-job.h"
+#include "rlimit-util.h"
#include "rm-rf.h"
#include "signal-util.h"
#include "siphash24.h"
@@ -472,6 +473,8 @@ int pull_verify(PullJob *main_job,
_exit(EXIT_FAILURE);
}
+ (void) rlimit_nofile_safe();
+
cmd[k++] = strjoina("--homedir=", gpg_home);
/* We add the user keyring only to the command line