diff options
author | Andreas Schneider <asn@samba.org> | 2015-11-04 11:21:23 +0100 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2015-11-04 15:11:20 +0100 |
commit | 1e2f53a6db5b9163ece72b0d75396b5816464460 (patch) | |
tree | cd66027b5e61ba8add6f89347736f417b86a15c1 | |
parent | f24f91eb2064ab04f7f289f73a443aafc45649e4 (diff) | |
download | socket_wrapper-1e2f53a6db5b9163ece72b0d75396b5816464460.tar.gz socket_wrapper-1e2f53a6db5b9163ece72b0d75396b5816464460.tar.xz socket_wrapper-1e2f53a6db5b9163ece72b0d75396b5816464460.zip |
swrap: Automatically bind an ephemeral port if needed
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r-- | src/socket_wrapper.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index b43c877..9ba212b 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3154,6 +3154,14 @@ static int swrap_listen(int s, int backlog) return libc_listen(s, backlog); } + if (si->bound == 0) { + ret = swrap_auto_bind(s, si, si->family); + if (ret == -1) { + errno = EADDRINUSE; + return ret; + } + } + ret = libc_listen(s, backlog); return ret; |