SOURCES: portmap-misc.patch - cleanup and update from debian - add...

baggins baggins at pld-linux.org
Fri Jan 6 19:21:25 CET 2006


Author: baggins                      Date: Fri Jan  6 18:21:25 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- cleanup and update from debian
- added chroot and bind ip options

---- Files affected:
SOURCES:
   portmap-misc.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/portmap-misc.patch
diff -u SOURCES/portmap-misc.patch:1.1 SOURCES/portmap-misc.patch:1.2
--- SOURCES/portmap-misc.patch:1.1	Sat Jul 15 08:16:18 2000
+++ SOURCES/portmap-misc.patch	Fri Jan  6 19:21:20 2006
@@ -1,21 +1,24 @@
 diff -Nru portmap_5beta/daemon.c portmap_5beta.new/daemon.c
 --- portmap_5beta/daemon.c	Thu Jun 11 22:53:12 1992
 +++ portmap_5beta.new/daemon.c	Wed Jul 12 21:24:57 2000
-@@ -35,7 +35,9 @@
- static char sccsid[] = "@(#)daemon.c	5.3 (Berkeley) 12/28/90";
+@@ -36,11 +36,8 @@
  #endif /* LIBC_SCCS and not lint */
  
-+#include <sys/types.h>
  #include <fcntl.h>
+-
+-/* From unistd.h */
+-#define STDIN_FILENO	0
+-#define STDOUT_FILENO	1
+-#define STDERR_FILENO	2
 +#include <unistd.h>
- 
- /* From unistd.h */
- #define STDIN_FILENO	0
-@@ -44,7 +46,7 @@
++#include <sys/types.h>
  
  /* From paths.h */
  #define _PATH_DEVNULL	"/dev/null"
--
+@@ -44,6 +46,7 @@
+ /* From paths.h */
+ #define _PATH_DEVNULL	"/dev/null"
+ 
 +int
  daemon(nochdir, noclose)
  	int nochdir, noclose;
@@ -23,35 +26,28 @@
 diff -Nru portmap_5beta/from_local.c portmap_5beta.new/from_local.c
 --- portmap_5beta/from_local.c	Fri May 31 15:52:58 1996
 +++ portmap_5beta.new/from_local.c	Wed Jul 12 21:24:57 2000
-@@ -46,11 +46,14 @@
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <stdio.h>
-+#include <unistd.h>
- #include <netdb.h>
- #include <netinet/in.h>
+@@ -51,6 +51,9 @@
  #include <net/if.h>
  #include <sys/ioctl.h>
  #include <syslog.h>
 +#include <stdlib.h>
 +#include <string.h>
++#include <unistd.h>
  
  #ifndef TRUE
  #define	TRUE	1
-@@ -95,7 +98,7 @@
- }
+@@ -96,6 +99,7 @@
  
  /* find_local - find all IP addresses for this host */
--
+ 
 +int
  find_local()
  {
      struct ifconf ifc;
-@@ -153,7 +156,7 @@
- }
+@@ -154,6 +158,7 @@
  
  /* from_local - determine whether request comes from the local system */
--
+ 
 +int
  from_local(addr)
  struct sockaddr_in *addr;
@@ -59,15 +55,21 @@
 diff -Nru portmap_5beta/pmap_check.c portmap_5beta.new/pmap_check.c
 --- portmap_5beta/pmap_check.c	Sun Jul  7 10:49:10 1996
 +++ portmap_5beta.new/pmap_check.c	Wed Jul 12 21:26:14 2000
-@@ -35,7 +35,7 @@
- #ifndef lint
- static char sccsid[] = "@(#) pmap_check.c 1.8 96/07/07 10:49:10";
+@@ -41,10 +41,14 @@
+ #include <syslog.h>
+ #include <netdb.h>
+ #include <sys/signal.h>
++#include <grp.h>
+ #ifdef SYSV40
+ #include <netinet/in.h>
+ #include <rpc/rpcent.h>
  #endif
--
++#include <sys/types.h>
 +#include <unistd.h>
- #include <rpc/rpc.h>
- #include <rpc/pmap_prot.h>
- #include <syslog.h>
++#include <tcpd.h>
+ 
+ extern char *inet_ntoa();
+ 
 @@ -68,6 +68,9 @@
  
  /* A handful of macros for "readability". */
@@ -78,7 +80,7 @@
  #define	good_client(a) hosts_ctl("portmap", "", inet_ntoa(a->sin_addr), "")
  
  #define reserved_port(p) (IPPORT_RESERVED/2 < (p) && (p) < IPPORT_RESERVED)
-@@ -110,6 +113,7 @@
+@@ -110,6 +110,7 @@
  
  /* check_default - additional checks for NULL, DUMP, GETPORT and unknown */
  
@@ -86,29 +88,26 @@
  check_default(addr, proc, prog)
  struct sockaddr_in *addr;
  u_long  proc;
-@@ -127,7 +131,7 @@
- }
+@@ -128,6 +142,7 @@
  
  /* check_privileged_port - additional checks for privileged-port updates */
--
+ 
 +int
  check_privileged_port(addr, proc, prog, port)
  struct sockaddr_in *addr;
  u_long  proc;
-@@ -147,7 +151,7 @@
+@@ -173,6 +188,7 @@
  
- #ifdef LOOPBACK_SETUNSET
+ #else
  
--check_setunset(xprt, ludp_xprt, ltcp_xprt, proc, prog, port)
-+int check_setunset(xprt, ludp_xprt, ltcp_xprt, proc, prog, port)
- SVCXPRT *xprt;
- SVCXPRT *ludp_xprt;
- SVCXPRT *ltcp_xprt;
-@@ -196,7 +200,7 @@
- #endif
++int
+ check_setunset(addr, proc, prog, port)
+ struct sockaddr_in *addr;
+ u_long  proc;
+@@ -197,6 +213,7 @@
  
  /* check_callit - additional checks for forwarded requests */
--
+ 
 +int
  check_callit(addr, proc, prog, aproc)
  struct sockaddr_in *addr;
@@ -146,48 +145,125 @@
 diff -Nru portmap_5beta/pmap_dump.c portmap_5beta.new/pmap_dump.c
 --- portmap_5beta/pmap_dump.c	Thu Jun 11 22:53:16 1992
 +++ portmap_5beta.new/pmap_dump.c	Wed Jul 12 21:24:57 2000
-@@ -22,7 +22,7 @@
- #include <rpc/pmap_prot.h>
+@@ -10,9 +10,12 @@
+ #endif
+ 
+ #include <stdio.h>
++#include <unistd.h>
++#include <sys/socket.h>
++#include <arpa/inet.h>
+ #include <sys/types.h>
+-#ifdef SYSV40
+ #include <netinet/in.h>
++#ifdef SYSV40
+ #include <rpc/rpcent.h>
+ #else
+ #include <netdb.h>
+@@ -23,6 +23,20 @@
  
  static char *protoname();
--
+ 
++#ifndef INADDR_LOOPBACK
++#define INADDR_LOOPBACK ntohl(inet_addr("127.0.0.1"))
++#endif
++
++static void    get_myloopaddress(addrp)
++struct sockaddr_in *addrp;
++{
++    memset((char *) addrp, 0, sizeof(*addrp));
++    addrp->sin_family = AF_INET;
++    addrp->sin_port = htons(PMAPPORT);
++    addrp->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
++}
++
 +int
  main(argc, argv)
  int     argc;
  char  **argv;
+@@ -31,8 +45,21 @@
+     struct sockaddr_in addr;
+     register struct pmaplist *list;
+     register struct rpcent *rpc;
++    int c;
+ 
+-    get_myaddress(&addr);
++    get_myloopaddress(&addr);
+ 
++    while ((c = getopt(argc, argv, "i:")) != EOF) {
++	switch(c) {
++	case 'i':
++		if (inet_aton(optarg, &addr.sin_addr) != 0)
++			break;
++	default:
++		fprintf(stderr, "usage: %s [-i address]\n", argv[0]);
++		fprintf(stderr, "-i address: connect to portmapper on address\n");
++		exit(1);
++	}
++    }
++
+     for (list = pmap_getmaps(&addr); list; list = list->pml_next) {
+ 	rpc = getrpcbynumber((int) list->pml_map.pm_prog);
 diff -Nru portmap_5beta/pmap_set.c portmap_5beta.new/pmap_set.c
 --- portmap_5beta/pmap_set.c	Sat Jul  6 23:06:23 1996
 +++ portmap_5beta.new/pmap_set.c	Wed Jul 12 21:24:57 2000
-@@ -17,6 +17,9 @@
+@@ -17,6 +17,10 @@
  #include <rpc/rpc.h>
  #include <rpc/pmap_clnt.h>
  
-+int parse_line(char *buf, u_long *, u_long *, int *, unsigned *); 
++int parse_line(char *buf, u_long *prog, u_long *vers, int *prot,
++	       unsigned *port);
 +
 +int
  main(argc, argv)
  int     argc;
  char  **argv;
-@@ -39,7 +42,7 @@
- }
+@@ -40,6 +44,7 @@
  
  /* parse_line - convert line to numbers */
--
+ 
 +int
  parse_line(buf, prog, vers, prot, port)
  char   *buf;
  u_long *prog;
+@@ -47,9 +52,9 @@
+ int    *prot;
+ unsigned *port;
+ {
+-    char    proto_name[BUFSIZ];
++    char    proto_name[512];
+ 
+-    if (sscanf(buf, "%lu %lu %s %u", prog, vers, proto_name, port) != 4) {
++    if (sscanf(buf, "%lu %lu %255s %u", prog, vers, proto_name, port) != 4) {
+ 	return (0);
+     }
+     if (strcmp(proto_name, "tcp") == 0) {
 diff -Nru portmap_5beta/portmap.c portmap_5beta.new/portmap.c
 --- portmap_5beta/portmap.c	Sat Jul  6 23:06:24 1996
 +++ portmap_5beta.new/portmap.c	Wed Jul 12 21:24:57 2000
-@@ -83,6 +83,7 @@
+@@ -80,6 +80,10 @@
+  * Mountain View, California  94043
+  */
+ 
++#if defined(__GLIBC__)
++#define _BSD_SOURCE 1	/* for daemon(3) */
++#include <rpc/xdr.h>
++#endif /* __GLIBC__ */
  #include <rpc/rpc.h>
  #include <rpc/pmap_prot.h>
  #include <stdio.h>
+@@ -91,9 +95,10 @@
+ #include <sys/signal.h>
+ #include <sys/time.h>
+ #include <sys/resource.h>
+-#ifdef SYSV40
+ #include <netinet/in.h>
+-#endif
++#include <sys/types.h>
 +#include <unistd.h>
- #include <syslog.h>
- #include <netdb.h>
- #include <sys/socket.h>
++#include <arpa/inet.h>
+ #include <errno.h>
+ #include <string.h>
+ #include <stdlib.h>
 @@ -148,6 +149,7 @@
  #endif
  #endif
@@ -196,6 +272,76 @@
  main(argc, argv)
  	int argc;
  	char **argv;
+@@ -157,22 +163,31 @@
+ 	struct sockaddr_in addr;
+ 	int len = sizeof(struct sockaddr_in);
+ 	register struct pmaplist *pml;
++	char *chroot_path = NULL;
++	struct in_addr bindaddr;
++	int have_bindaddr = 0;
+ 
+-	while ((c = getopt(argc, argv, "dv")) != EOF) {
++	while ((c = getopt(argc, argv, "dt:vi:n")) != EOF) {
+ 		switch (c) {
+ 
+ 		case 'd':
+ 			debugging = 1;
+ 			break;
+-
++		case 't':
++			chroot_path = optarg;
++			break;
+ 		case 'v':
+ 			verboselog = 1;
+ 			break;
+-
++		case 'i':
++			have_bindaddr = inet_aton(optarg, &bindaddr);
++			break;
+ 		default:
+-			(void) fprintf(stderr, "usage: %s [-dv]\n", argv[0]);
++			(void) fprintf(stderr, "usage: %s [-dv] [-t dir] [-i address]\n", argv[0]);
+ 			(void) fprintf(stderr, "-d: debugging mode\n");
++			(void) fprintf(stderr, "-t dir: chroot into dir\n");
+ 			(void) fprintf(stderr, "-v: verbose logging\n");
++			(void) fprintf(stderr, "-i address: bind to address\n");
+ 			exit(1);
+ 		}
+ 	}
+@@ -201,6 +218,9 @@
+ 	addr.sin_addr.s_addr = 0;
+ 	addr.sin_family = AF_INET;
+ 	addr.sin_port = htons(PMAPPORT);
++	if (have_bindaddr)
++		memcpy(&addr.sin_addr, &bindaddr, sizeof(bindaddr));
++
+ 	if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
+ 		syslog(LOG_ERR, "cannot bind udp: %m");
+ 		exit(1);
+@@ -227,7 +247,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,6 +300,14 @@
+ 	(void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE);
+ 
+ 	/* additional initializations */
++	if (chroot_path)
++	{
++		if (-1 == chroot(chroot_path))
++		{
++			syslog(LOG_ERR, "couldn't do chroot");
++			exit(1);
++		}
++	}
+ 	check_startup();
+ #ifdef IGNORE_SIGCHLD			/* Lionel Cons <cons at dxcern.cern.ch> */
+ 	(void)signal(SIGCHLD, SIG_IGN);
 @@ -289,6 +291,7 @@
  	svc_run();
  	syslog(LOG_ERR, "run_svc returned unexpectedly");
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/portmap-misc.patch?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list