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
This commit is contained in:
Jim Rees 2006-01-20 15:17:46 +00:00
parent 4b81d0eb0f
commit c99880b289

View File

@ -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;