summaryrefslogtreecommitdiffstats
path: root/sys/rpc/rpcclnt.c
diff options
context:
space:
mode:
authorrees <rees@FreeBSD.org>2006-01-20 15:17:46 +0000
committerrees <rees@FreeBSD.org>2006-01-20 15:17:46 +0000
commitf4bb03bde03a250ed963417ac7fe3fbf293f2ebf (patch)
tree85da085470ef67567630deb1635d20456538233f /sys/rpc/rpcclnt.c
parentfc1f7144ffe98177ac28645dfa164f4a3532784f (diff)
downloadFreeBSD-src-f4bb03bde03a250ed963417ac7fe3fbf293f2ebf.zip
FreeBSD-src-f4bb03bde03a250ed963417ac7fe3fbf293f2ebf.tar.gz
Use thread0 instead of user's thread for sobind.
This fixes reconnect after, for example, tcp idle disconnection. Previously this would fail if a normal user tried to bind to a privileged port. Submitted by: cel@citi.umich.edu MFC after: 1 week
Diffstat (limited to 'sys/rpc/rpcclnt.c')
-rw-r--r--sys/rpc/rpcclnt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/rpc/rpcclnt.c b/sys/rpc/rpcclnt.c
index a70a287..0619cb6 100644
--- a/sys/rpc/rpcclnt.c
+++ b/sys/rpc/rpcclnt.c
@@ -423,7 +423,11 @@ rpcclnt_connect(rpc, td)
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(0);
- error = sobind(so, (struct sockaddr *) & sin, td);
+ /*
+ * &thread0 gives us root credentials to ensure sobind
+ * will give us a reserved ephemeral port.
+ */
+ error = sobind(so, (struct sockaddr *) & sin, &thread0);
#endif
if (error)
goto bad;
OpenPOWER on IntegriCloud