From c0f7cd1a2a12e1f49583bfd178b6416c79d09535 Mon Sep 17 00:00:00 2001 From: Peter Pentchev Date: Thu, 4 Mar 2004 15:52:28 +0000 Subject: [PATCH] Make rpc.lockd bind to a reserved port, since there are NFS clients which ignore NLM requests not coming from a reserved port. PR: 56500 Submitted by: Jonathan Lennox MFC after: 1 week --- usr.sbin/rpc.lockd/lock_proc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/usr.sbin/rpc.lockd/lock_proc.c b/usr.sbin/rpc.lockd/lock_proc.c index edd511729d7..076f0ee7168 100644 --- a/usr.sbin/rpc.lockd/lock_proc.c +++ b/usr.sbin/rpc.lockd/lock_proc.c @@ -197,6 +197,8 @@ get_client(host_addr, vers) const char *netid; struct netconfig *nconf; char host[NI_MAXHOST]; + uid_t old_euid; + int clnt_fd; gettimeofday(&time_now, NULL); @@ -271,6 +273,22 @@ get_client(host_addr, vers) return NULL; } + /* Get the FD of the client, for bindresvport. */ + clnt_control(client, CLGET_FD, &clnt_fd); + + /* Regain root privileges, for bindresvport. */ + old_euid = geteuid(); + seteuid(0); + + /* + * Bind the client FD to a reserved port. + * Some NFS servers reject any NLM request from a non-reserved port. + */ + bindresvport(clnt_fd, NULL); + + /* Drop root privileges again. */ + seteuid(old_euid); + /* Success - update the cache entry */ clnt_cache_ptr[clnt_cache_next_to_use] = client; memcpy(&clnt_cache_addr[clnt_cache_next_to_use], host_addr,