Skip to contentSkip to conversation

allow TCP-only portmapper

PATCH In review Dan Horák 2 participants 2 messages Apr 11, 2023 – Apr 21, 2023

Subsystems (2)
lore
Share & tools
lore

Dan Horák

author
#0 lore raw

PATCH 1/1 allow TCP-only portmapper

Code that works in GLIBC's runrpc implementation fails with libtirpc. libtirpc forces the RPC library to talk to the portmapper via UDP, even when the client specifies TCP. This breaks existing code which expect the protocol specified to be honored, even when talking to portmapper.

This is upstreaming of an old patch by Rob Riggs reported in Fedora.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1725329

---
 src/rpcb_clnt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
src/rpcb_clnt.c +3 -6
index 9a9de69..d178d86 100644
@@ -496,11 +496,7 @@ getpmaphandle(nconf, hostname, 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) {
+	if (nconf == NULL) {
 		struct netconfig *newnconf;
 
 		if ((newnconf = getnetconfigent("udp")) == NULL) {
@@ -509,7 +505,8 @@ getpmaphandle(nconf, hostname, tgtaddr)
 		}
 		client = getclnthandle(hostname, newnconf, tgtaddr);
 		freenetconfigent(newnconf);
-	} else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
+	} else if (strcmp(nconf->nc_proto, NC_UDP) == 0 ||
+	    strcmp(nconf->nc_proto, NC_TCP) == 0) {
 		if (strcmp(nconf->nc_protofmly, NC_INET) != 0)
 			return NULL;
 		client = getclnthandle(hostname, nconf, tgtaddr);
Signature · 1 line
2.40.0
#1 lore raw
Quoted 11 lines · Dan Horák

Code that works in GLIBC's runrpc implementation fails with libtirpc. libtirpc forces the RPC library to talk to the portmapper via UDP, even when the client specifies TCP. This breaks existing code which expect the protocol specified to be honored, even when talking to portmapper.

This is upstreaming of an old patch by Rob Riggs reported in Fedora.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1725329

Committed... (tag: libtirpc-1-3-4-rc1)

steved.

Quoted 31 lines
---
  src/rpcb_clnt.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
src/rpcb_clnt.c +3 -6
index 9a9de69..d178d86 100644
@@ -496,11 +496,7 @@ getpmaphandle(nconf, hostname, 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) {
+	if (nconf == NULL) {
  		struct netconfig *newnconf;
 
  		if ((newnconf = getnetconfigent("udp")) == NULL) {
@@ -509,7 +505,8 @@ getpmaphandle(nconf, hostname, tgtaddr)
  		}
  		client = getclnthandle(hostname, newnconf, tgtaddr);
  		freenetconfigent(newnconf);
-	} else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
+	} else if (strcmp(nconf->nc_proto, NC_UDP) == 0 ||
+	    strcmp(nconf->nc_proto, NC_TCP) == 0) {
  		if (strcmp(nconf->nc_protofmly, NC_INET) != 0)
  			return NULL;
  		client = getclnthandle(hostname, nconf, tgtaddr);