tree-wide: port various places over to use new rearrange_stdio()

This commit is contained in:
Lennart Poettering
2018-03-02 11:42:10 +01:00
parent 8bb2db738e
commit 2b33ab0957
11 changed files with 39 additions and 169 deletions
+3 -17
View File
@@ -54,26 +54,12 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
}
if (r == 0) {
char *empty_env = NULL;
int nullfd;
if (dup3(pipe_fds[1], STDOUT_FILENO, 0) < 0)
safe_close(pipe_fds[0]);
if (rearrange_stdio(-1, pipe_fds[1], -1) < 0)
_exit(EXIT_FAILURE);
safe_close_above_stdio(pipe_fds[0]);
safe_close_above_stdio(pipe_fds[1]);
nullfd = open("/dev/null", O_RDWR);
if (nullfd < 0)
_exit(EXIT_FAILURE);
if (dup3(nullfd, STDIN_FILENO, 0) < 0)
_exit(EXIT_FAILURE);
if (dup3(nullfd, STDERR_FILENO, 0) < 0)
_exit(EXIT_FAILURE);
safe_close_above_stdio(nullfd);
close_all_fds(NULL, 0);
execle("/usr/bin/getent", "getent", database, key, NULL, &empty_env);