diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-11-30 15:18:45 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-12-15 23:36:22 +0100 |
commit | 9f4c3da734adbabf457074563f3fb3fae7b85585 (patch) | |
tree | bfb3b1eaadbb912547fc325b66eb199e535eda9d /source4/lib/socket | |
parent | d581c9d284e7c635b0379d57e95cb32e682f0f02 (diff) | |
download | samba-9f4c3da734adbabf457074563f3fb3fae7b85585.tar.gz samba-9f4c3da734adbabf457074563f3fb3fae7b85585.tar.bz2 samba-9f4c3da734adbabf457074563f3fb3fae7b85585.zip |
s4-socket: use set_close_on_exec()
this prevents a fd leak to child processes
Diffstat (limited to 'source4/lib/socket')
-rw-r--r-- | source4/lib/socket/socket_ip.c | 4 | ||||
-rw-r--r-- | source4/lib/socket/socket_unix.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c index cab51beafb..d2d57798d4 100644 --- a/source4/lib/socket/socket_ip.c +++ b/source4/lib/socket/socket_ip.c @@ -50,6 +50,8 @@ static NTSTATUS ipv4_init(struct socket_context *sock) return map_nt_error_from_unix_common(errno); } + set_close_on_exec(sock->fd); + sock->backend_name = "ipv4"; sock->family = AF_INET; @@ -610,6 +612,8 @@ static NTSTATUS ipv6_init(struct socket_context *sock) return map_nt_error_from_unix_common(errno); } + set_close_on_exec(sock->fd); + sock->backend_name = "ipv6"; sock->family = AF_INET6; diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index d492f01268..ab9b06df1b 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -59,6 +59,8 @@ static NTSTATUS unixdom_init(struct socket_context *sock) sock->backend_name = "unix"; + set_close_on_exec(sock->fd); + return NT_STATUS_OK; } @@ -198,6 +200,8 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, } } + set_close_on_exec(new_fd); + (*new_sock) = talloc(NULL, struct socket_context); if (!(*new_sock)) { close(new_fd); |