SHA256
1
0
forked from pool/libtirpc
libtirpc/004-getpmaphandle.patch
Olaf Kirch c3b2cb84b1 Accepting request 265252 from home:kukuk:NIS
- Update to upstream 0.2.5 release
- Add symbol versioning to fix symbol conflicts
  (001-symbol-versions-v2.patch), but disable until commited upstream
- Adjust libtirpc-clnt_broadcast_fix.patch and rename to
  002-clnt_broadcast_fix.patch
- Adjust libtirpc-rpc_broadcast_misformed_replies.patch and rename
  to 003-rpc_broadcast_misformed_replies.patch
- Rename libtirpc-getpmaphandle.patch to 004-getpmaphandle.patch
- Adjust libtirpc-bindresvport_blacklist.patch and rename to 
  000-bindresvport_blacklist.patch
- Drop libtirpc-pmap-setunset.patch, not needed anymore
- Apply libtirpc-new-path-rpcbindsock.patch only on openSUSE 13.1
  and later

OBS-URL: https://build.opensuse.org/request/show/265252
OBS-URL: https://build.opensuse.org/package/show/Base:System/libtirpc?expand=0&rev=41
2014-12-18 13:26:10 +00:00

102 lines
2.7 KiB
Diff

commit 258824b705df18d171eaf072cfda692504e3649e
Author: Olaf Kirch <okir@suse.de>
Date: Mon Aug 23 12:58:41 2010 +0200
Introduce new helper function getpmaphandle
This moves some code for creation of PMAP handles out of the getaddr
code and into a function of its own.
Signed-off-by: Olaf Kirch <okir@suse.de>
diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
index a800128..962d9c7 100644
--- a/src/rpcb_clnt.c
+++ b/src/rpcb_clnt.c
@@ -434,6 +434,44 @@ out_err:
return (client);
}
+/*
+ * Create a PMAP client handle.
+ */
+static CLIENT *
+getpmaphandle(nconf, hostname, tgtaddr)
+ const struct netconfig *nconf;
+ const char *hostname;
+ char **tgtaddr;
+{
+ CLIENT *client = NULL;
+ rpcvers_t pmapvers = 2;
+
+ /*
+ * Try UDP only - there are some portmappers out
+ * there that use UDP only.
+ */
+ if (nconf == NULL || strcmp(nconf->nc_proto, NC_TCP) == 0) {
+ struct netconfig *newnconf;
+
+ if ((newnconf = getnetconfigent("udp")) == NULL) {
+ rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
+ return NULL;
+ }
+ client = getclnthandle(hostname, newnconf, tgtaddr);
+ freenetconfigent(newnconf);
+ } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
+ if (strcmp(nconf->nc_protofmly, NC_INET) != 0)
+ return NULL;
+ client = getclnthandle(hostname, nconf, tgtaddr);
+ }
+
+ /* Set version */
+ if (client != NULL)
+ CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
+
+ return client;
+}
+
/* XXX */
#define IN4_LOCALHOST_STRING "127.0.0.1"
#define IN6_LOCALHOST_STRING "::1"
@@ -770,34 +808,20 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp)
if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
u_short port = 0;
struct netbuf remote;
- rpcvers_t pmapvers = 2;
struct pmap pmapparms;
- /*
- * Try UDP only - there are some portmappers out
- * there that use UDP only.
- */
- if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
- struct netconfig *newnconf;
-
- if ((newnconf = getnetconfigent("udp")) == NULL) {
- rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
- return (NULL);
- }
- client = getclnthandle(host, newnconf, &parms.r_addr);
- freenetconfigent(newnconf);
- } else if (strcmp(nconf->nc_proto, NC_UDP) == 0)
- client = getclnthandle(host, nconf, &parms.r_addr);
- else
+ if (strcmp(nconf->nc_proto, NC_UDP) != 0
+ && strcmp(nconf->nc_proto, NC_TCP) != 0)
goto try_rpcbind;
+
+ client = getpmaphandle(nconf, host, &parms.r_addr);
if (client == NULL)
return (NULL);
/*
- * Set version and retry timeout.
+ * Set retry timeout.
*/
CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime);
- CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
pmapparms.pm_prog = program;
pmapparms.pm_vers = version;