[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

patches for rpc utility programs



I'm still waiting to hear from Roland about the rpc_svc() glibc bug, but in
the meantime I'll try to start submitting patches... 

I've grabbed the source for the debian netbase-3.16 package to compile
rpcgen, rpcinfo and portmap. But who is supposed to get theese patches?

The short story is, apply attached patches, and then compile in these
directories:

netbase-3.16/netkit-base/rpcgen/
netbase-3.16/netkit-base/rpcinfo/
netbase-3.16/portmap/

About the patches:

The rpcgen patch is a straightforward replace-MAXPATHLEN-with-malloc thingie.
This should be submitted to the upstream maintainer.

I'm not quite that happy with the portmap patch:

from_local() uses ioctl() to get all active network interfaces. Hurd has no
devices to support this. I want a generic, portable libc function that
returns a list of interfaces. Somebody add that to the glibc wishlist?

Anyway, I have avoided from_local() by turning off HOSTS_ACCESS and turning
on LOOPBACK_SETUNSET (set and unset only from loopback-devices.)
I can rewrite the relevant parts of pmap_check.c to enable HOSTS_ACCESS
(libwrap) without using from_local(). However this will be incompatible
with the linux behavore, as you will have to add local address(es) to
/etc/hosts.allow. Any opinions?

The HURD does have strerror() but not sys_errlist/sys_nerr, so obviosly we
don't want strerror.o.

The changes to portmap.c should be ok, they're there to supply correct 
information to the next person debugging this program. These should be
submitted to the upstream maintainer.

	Steinar
diff -ru netbase-3.16.debianorig/netkit-base/rpcgen/rpc_main.c netbase-3.16/netkit-base/rpcgen/rpc_main.c
--- netbase-3.16.debianorig/netkit-base/rpcgen/rpc_main.c	Sun Mar 19 23:26:43 2000
+++ netbase-3.16/netkit-base/rpcgen/rpc_main.c	Mon Mar 20 21:48:42 2000
@@ -57,6 +57,7 @@
 
 #define SVR4_CPP "/usr/bin/cpp"
 #define SUNOS_CPP "/lib/cpp"
+#define CPP_NAME "/cpp"		/* appended to path from -Y */
 static int cppDefined = 0;          /* explicit path for C preprocessor */
 
 struct commandline {
@@ -79,7 +80,7 @@
 static const char *svcclosetime = "120";
 static const char *CPP = SVR4_CPP;
 static char CPPFLAGS[] = "-C";
-static char pathbuf[MAXPATHLEN + 1];
+static char *pathbuf = 0;
 static const char *allv[] = {
 	"rpcgen", "-s", "udp", "-s", "tcp",
 };
@@ -998,8 +999,16 @@
 					if (++i == argc) {
 						return (0);
 					}
+					free(pathbuf);
+					pathbuf=malloc(strlen(argv[i])
+						+strlen(CPP_NAME)+1);
+					if (!pathbuf) {
+						fprintf(stderr,
+							"failed in malloc");
+						exit(1);
+					}
 					(void) strcpy(pathbuf, argv[i]);
-					(void) strcat(pathbuf, "/cpp");
+					(void) strcat(pathbuf, CPP_NAME);
 					CPP = pathbuf;
 					cppDefined = 1;
 					goto nextarg;
diff -ru netbase-3.16.debianorig/portmap/Makefile netbase-3.16/portmap/Makefile
--- netbase-3.16.debianorig/portmap/Makefile	Sun Mar 19 23:26:42 2000
+++ netbase-3.16/portmap/Makefile	Tue Mar 21 00:48:09 2000
@@ -15,7 +15,7 @@
 # no access control tables. The local system, since it runs the portmap
 # daemon, is always treated as an authorized host.
 
-HOSTS_ACCESS= -DHOSTS_ACCESS
+#HOSTS_ACCESS= -DHOSTS_ACCESS
 #WRAP_LIB = $(WRAP_DIR)/libwrap.a
 WRAP_LIB = /usr/lib/libwrap.a
 
@@ -60,7 +60,7 @@
 # probably much easier to just block port UDP and TCP ports 111 on
 # your routers.
 #
-# LOOPBACK = -DLOOPBACK_SETUNSET
+LOOPBACK = -DLOOPBACK_SETUNSET
 
 # When the portmapper cannot find any local interfaces (it will complain
 # to the syslog daemon) your system probably has variable-length socket
@@ -86,7 +86,7 @@
 
 # Auxiliary object files that may be missing from your C library.
 #
-AUX	= daemon.o strerror.o
+AUX	= daemon.o
 
 # NEXTSTEP is a little different. The following seems to work with NS 3.2
 #
@@ -119,8 +119,8 @@
 COPT	= $(CONST) $(HOSTS_ACCESS) $(CHECK_PORT) \
 	$(SYS) -DFACILITY=$(FACILITY) $(ULONG) $(ZOMBIES) $(SA_LEN) \
 	$(LOOPBACK) $(SETPGRP)
-CFLAGS	= $(COPT) -O2 $(NSARCHS)
-OBJECTS	= portmap.o pmap_check.o from_local.o $(AUX)
+CFLAGS	= $(COPT) -O2 -g $(NSARCHS)
+OBJECTS	= portmap.o pmap_check.o $(AUX)
 
 all:	portmap pmap_dump pmap_set
 
diff -ru netbase-3.16.debianorig/portmap/portmap.c netbase-3.16/portmap/portmap.c
--- netbase-3.16.debianorig/portmap/portmap.c	Sun Mar 19 23:26:42 2000
+++ netbase-3.16/portmap/portmap.c	Sun Mar 19 23:43:00 2000
@@ -230,7 +230,7 @@
 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on);
 #endif
 	if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
-		syslog(LOG_ERR, "cannot bind udp: %m");
+		syslog(LOG_ERR, "cannot bind tcp: %m");
 		exit(1);
 	}
 	if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE))
@@ -280,7 +280,10 @@
 	}
 #endif
 
-	(void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE);
+	if (!svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE)) {
+		syslog(LOG_ERR, "cannot register myself");
+		exit(1);
+	}
 
 	/* additional initializations */
 	check_startup();

Reply to: