diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/child_common.c | 22 | ||||
-rw-r--r-- | src/util/child_common.h | 12 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/util/child_common.c b/src/util/child_common.c index d3f488d18..d632cd4ec 100644 --- a/src/util/child_common.c +++ b/src/util/child_common.c @@ -729,17 +729,18 @@ fail: return ret; } -errno_t exec_child(TALLOC_CTX *mem_ctx, - int *pipefd_to_child, int *pipefd_from_child, - const char *binary, int debug_fd, - const char *extra_argv[]) +errno_t exec_child_ex(TALLOC_CTX *mem_ctx, + int *pipefd_to_child, int *pipefd_from_child, + const char *binary, int debug_fd, + const char *extra_argv[], + int child_in_fd, int child_out_fd) { int ret; errno_t err; char **argv; close(pipefd_to_child[1]); - ret = dup2(pipefd_to_child[0], STDIN_FILENO); + ret = dup2(pipefd_to_child[0], child_in_fd); if (ret == -1) { err = errno; DEBUG(SSSDBG_CRIT_FAILURE, @@ -748,7 +749,7 @@ errno_t exec_child(TALLOC_CTX *mem_ctx, } close(pipefd_from_child[0]); - ret = dup2(pipefd_from_child[1], STDOUT_FILENO); + ret = dup2(pipefd_from_child[1], child_out_fd); if (ret == -1) { err = errno; DEBUG(SSSDBG_CRIT_FAILURE, @@ -770,6 +771,15 @@ errno_t exec_child(TALLOC_CTX *mem_ctx, return err; } +errno_t exec_child(TALLOC_CTX *mem_ctx, + int *pipefd_to_child, int *pipefd_from_child, + const char *binary, int debug_fd) +{ + return exec_child_ex(mem_ctx, pipefd_to_child, pipefd_from_child, + binary, debug_fd, NULL, + STDIN_FILENO, STDOUT_FILENO); +} + void child_cleanup(int readfd, int writefd) { int ret; diff --git a/src/util/child_common.h b/src/util/child_common.h index e659388ec..369de71a1 100644 --- a/src/util/child_common.h +++ b/src/util/child_common.h @@ -112,10 +112,18 @@ void child_sig_handler(struct tevent_context *ev, int count, void *__siginfo, void *pvt); /* Never returns EOK, ether returns an error, or doesn't return on success */ +errno_t exec_child_ex(TALLOC_CTX *mem_ctx, + int *pipefd_to_child, int *pipefd_from_child, + const char *binary, int debug_fd, + const char *extra_argv[], + int child_in_fd, int child_out_fd); + +/* Same as exec_child_ex() except child_in_fd is set to STDIN_FILENO and + * child_out_fd is set to STDOUT_FILENO and extra_argv is always NULL. + */ errno_t exec_child(TALLOC_CTX *mem_ctx, int *pipefd_to_child, int *pipefd_from_child, - const char *binary, int debug_fd, - const char *extra_argv[]); + const char *binary, int debug_fd); void child_cleanup(int readfd, int writefd); |