1
0
forked from rpms/rpcbind
rpcbind/rpcbind-0.1.6-pmap-ipv4-only.patch
Steve Dickson e10053ca4d - Added usptream patches 01 thru 03 that do:
Introduce helpers for ipprot/netid mapping
Change how we decide on the netids to use for portmap
Simplify port live check in pmap_svc.c
2008-09-16 15:48:09 +00:00

108 lines
3.2 KiB
Diff

commit 1a94b830a6b5a248faa6fa0e4b7818d9394f6369
Author: Olaf Kirch <okir@suse.de>
Date: Tue Sep 16 10:15:39 2008 -0400
Change how we decide on the netids to use for portmap
The current code will try to use either udp or udp6, and either tcp or
tcp6 for its portmap emulation code. Enabling eg both tcp6 and tcp in
the netconfig file will cause error messages, and cause rpcbind to not
register itself on the second transport (tcp).
This is not what we want.
I believe portmap emulation should only be enabled over IPv4.
There's no point in enabling it over IPv6.
Signed-off-by: okir@suse.de
Signed-off-by: Steve Dickson <steved@redhat.com>
diff --git a/src/rpcbind.c b/src/rpcbind.c
index 5e7e744..dc6f66b 100644
--- a/src/rpcbind.c
+++ b/src/rpcbind.c
@@ -167,10 +167,6 @@ main(int argc, char *argv[])
syslog(LOG_ERR, "could not read /etc/netconfig");
exit(1);
}
-#ifdef PORTMAP
- udptrans = "";
- tcptrans = "";
-#endif
nconf = getnetconfigent("local");
if (nconf == NULL)
@@ -190,6 +186,13 @@ main(int argc, char *argv[])
}
endnetconfig(nc_handle);
+#ifdef PORTMAP
+ if (!udptrans)
+ udptrans = "";
+ if (!tcptrans)
+ tcptrans = "";
+#endif
+
/* catch the usual termination signals for graceful exit */
(void) signal(SIGCHLD, reap);
(void) signal(SIGINT, terminate);
@@ -545,15 +548,12 @@ init_transport(struct netconfig *nconf)
#ifdef PORTMAP
/*
- * Register both the versions for tcp/ip, udp/ip and local.
+ * Register both the versions for tcp/ip, udp/ip.
*/
- if (((strcmp(nconf->nc_protofmly, NC_INET) == 0 ||
- strcmp(nconf->nc_protofmly, NC_INET6) == 0) &&
- (strcmp(nconf->nc_proto, NC_TCP) == 0 ||
- strcmp(nconf->nc_proto, NC_UDP) == 0)) ||
- (strcmp(nconf->nc_netid, "unix") == 0) ||
- (strcmp(nconf->nc_netid, "local") == 0)) {
+ if (si.si_af == AF_INET &&
+ (si.si_proto == IPPROTO_TCP || si.si_proto == IPPROTO_UDP)) {
struct pmaplist *pml;
+
if (!svc_register(my_xprt, PMAPPROG, PMAPVERS,
pmap_service, 0)) {
syslog(LOG_ERR, "could not register on %s",
@@ -568,30 +568,18 @@ init_transport(struct netconfig *nconf)
pml->pml_map.pm_prog = PMAPPROG;
pml->pml_map.pm_vers = PMAPVERS;
pml->pml_map.pm_port = PMAPPORT;
- if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
- if (tcptrans[0]) {
- syslog(LOG_ERR,
- "cannot have more than one TCP transport");
- goto error;
- }
- tcptrans = strdup(nconf->nc_netid);
- pml->pml_map.pm_prot = IPPROTO_TCP;
+ pml->pml_map.pm_prot = si.si_proto;
- /* Let's snarf the universal address */
- /* "h1.h2.h3.h4.p1.p2" */
+ /* Stash away the universal address */
+ switch (si.si_proto) {
+ case IPPROTO_TCP:
+ tcptrans = strdup(nconf->nc_netid);
tcp_uaddr = taddr2uaddr(nconf, &taddr.addr);
- } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
- if (udptrans[0]) {
- syslog(LOG_ERR,
- "cannot have more than one UDP transport");
- goto error;
- }
+ break;
+ case IPPROTO_UDP:
udptrans = strdup(nconf->nc_netid);
- pml->pml_map.pm_prot = IPPROTO_UDP;
-
- /* Let's snarf the universal address */
- /* "h1.h2.h3.h4.p1.p2" */
udp_uaddr = taddr2uaddr(nconf, &taddr.addr);
+ break;
}
pml->pml_next = list_pml;
list_pml = pml;