From c99880b289c26700bfef96b52fec8d3610d67dee Mon Sep 17 00:00:00 2001 From: Jim Rees Date: Fri, 20 Jan 2006 15:17:46 +0000 Subject: [PATCH] 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 --- sys/rpc/rpcclnt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/rpc/rpcclnt.c b/sys/rpc/rpcclnt.c index a70a287e922..0619cb6f947 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;