diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-11-30 15:18:29 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-12-22 14:00:06 +0100 |
commit | 4ecac6067f6637b160f3beff775c43118e6b684a (patch) | |
tree | 882014db15502e9604a42d0a3068dceb92cd46ff /lib | |
parent | 81c564798c84a39c92c2c33d57151a9064940152 (diff) | |
download | samba-4ecac6067f6637b160f3beff775c43118e6b684a.tar.gz samba-4ecac6067f6637b160f3beff775c43118e6b684a.tar.bz2 samba-4ecac6067f6637b160f3beff775c43118e6b684a.zip |
runcmd: use set_close_on_exec()
this prevents a fd leak to child processes
Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Thu Dec 22 14:00:06 CET 2011 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/util_runcmd.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c index 8a475ef301..cc274c21d5 100644 --- a/lib/util/util_runcmd.c +++ b/lib/util/util_runcmd.c @@ -135,6 +135,10 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx, set_blocking(state->fd_stderr, false); set_blocking(state->fd_stdin, false); + smb_set_close_on_exec(state->fd_stdin); + smb_set_close_on_exec(state->fd_stdout); + smb_set_close_on_exec(state->fd_stderr); + talloc_set_destructor(state, samba_runcmd_state_destructor); state->fde_stdout = tevent_add_fd(ev, state, @@ -197,6 +201,10 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx, dup2(p1[1], 1); dup2(p2[1], 2); + close(p1[1]); + close(p2[1]); + close(p3[0]); + argv = str_list_copy(state, discard_const_p(const char *, argv0)); if (!argv) { fprintf(stderr, "Out of memory in child\n"); |