From f4bb03bde03a250ed963417ac7fe3fbf293f2ebf Mon Sep 17 00:00:00 2001 From: rees Date: Fri, 20 Jan 2006 15:17:46 +0000 Subject: 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(-) (limited to 'sys/rpc/rpcclnt.c') 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; -- cgit v1.1