diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-05-23 17:53:19 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-05-23 17:53:19 +0000 |
commit | 7cfcf20b10c97faaf764f5c7784c4f2fa7922c5f (patch) | |
tree | 149a19f5f50b1433df714885fd986cdaefbee919 /sunrpc/pm_getmaps.c | |
parent | e975f7ef2955c34c381d84b2494b47018c3461ab (diff) |
2005-05-23 Ulrich Drepper <drepper@redhat.com>
* sunrpc/pm_getport.c (__get_socket): New function.
(pmap_getport): Use it to open a non-reserved socket to the portmapper
for TCP.
* include/rpc/pmap_clnt.h (__get_socket): Declare.
* sunrpc/pm_getmaps.c (pmap_getmaps): Use __get_socket to get an
non-reserved socket for the portmapper.
Based on a patch by Steve Dickson <steved@redhat.com>.
* sunrpc/bindrsvprt.c (bindresvport): Try harder to find a port.
If we tried looking at the usual range without success extend the
range to even lower ports.
Diffstat (limited to 'sunrpc/pm_getmaps.c')
-rw-r--r-- | sunrpc/pm_getmaps.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sunrpc/pm_getmaps.c b/sunrpc/pm_getmaps.c index d1d4ca8769..2a6876d9d8 100644 --- a/sunrpc/pm_getmaps.c +++ b/sunrpc/pm_getmaps.c @@ -44,9 +44,12 @@ static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro"; #include <rpc/pmap_clnt.h> #include <sys/socket.h> #include <netdb.h> +#include <stdbool.h> #include <stdio.h> #include <errno.h> #include <libintl.h> +#include <unistd.h> + /* * Get a copy of the current port maps. @@ -56,13 +59,19 @@ struct pmaplist * pmap_getmaps (struct sockaddr_in *address) { struct pmaplist *head = (struct pmaplist *) NULL; - int socket = -1; struct timeval minutetimeout; CLIENT *client; + bool closeit = false; minutetimeout.tv_sec = 60; minutetimeout.tv_usec = 0; address->sin_port = htons (PMAPPORT); + + /* Don't need a reserved port to get ports from the portmapper. */ + int socket = __get_socket (address); + if (socket != -1) + closeit = true; + client = INTUSE(clnttcp_create) (address, PMAPPROG, PMAPVERS, &socket, 50, 500); if (client != (CLIENT *) NULL) @@ -75,7 +84,9 @@ pmap_getmaps (struct sockaddr_in *address) } CLNT_DESTROY (client); } - /* (void)close(socket); CLNT_DESTROY already closed it */ + /* We only need to close the socket here if we opened it. */ + if (closeit) + (void) __close (socket); address->sin_port = 0; return head; } |