tree-wide: set FORK_RLIMIT_NOFILE_SAFE flag

No functional changes, just refactoring.
This commit is contained in:
Yu Watanabe
2023-02-07 14:39:49 +09:00
parent e955a7f460
commit f3f2d02e97
7 changed files with 8 additions and 29 deletions
+1 -4
View File
@@ -12,7 +12,6 @@
#include "mkdir.h"
#include "nspawn-setuid.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "signal-util.h"
#include "string-util.h"
#include "strv.h"
@@ -29,7 +28,7 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
if (pipe2(pipe_fds, O_CLOEXEC) < 0)
return log_error_errno(errno, "Failed to allocate pipe: %m");
r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid);
r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &pid);
if (r < 0) {
safe_close_pair(pipe_fds);
return r;
@@ -44,8 +43,6 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
(void) close_all_fds(NULL, 0);
(void) rlimit_nofile_safe();
execle("/usr/bin/getent", "getent", database, key, NULL, &empty_env);
execle("/bin/getent", "getent", database, key, NULL, &empty_env);
_exit(EXIT_FAILURE);