Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Aug 1996 12:54:09 -0700 (PDT)
From:      Julian Elischer <julian@current1.whistle.com>
To:        hackers@freebsd.org
Subject:   please comment on this:
Message-ID:  <199608061954.MAA12611@current1.whistle.com>

next in thread | raw e-mail | index | archive | help

Here at whistle, we want to run different services on different interfaces, so
here are some patches to allow inetd to bind to an address.

does anyone have any complaints about this feature?
is it in any way a security hole?

If I don't hear any problems or if people like it,
I'd like to add this to our sources..

julian

Index: inetd.8
===================================================================
RCS file: /cvs/freebsd/src/usr.sbin/inetd/inetd.8,v
retrieving revision 1.8
diff -c -r1.8 inetd.8
*** 1.8	1996/02/07 17:15:00
--- inetd.8	1996/08/06 19:29:15
***************
*** 44,49 ****
--- 44,51 ----
  .Op Fl d
  .Op Fl l
  .Op Fl R Ar rate
+ .Op Fl a Ar address
+ .Op Fl p Ar filename
  .Op Ar configuration file
  .Sh DESCRIPTION
  The
***************
*** 78,83 ****
--- 80,89 ----
  .It Fl R Ar rate
  Specifies the maximum number of times a service can be invoked
  in one minute; the default is 256.
+ .It Fl a
+ Specify a specific IP address to bind to.
+ .It Fl p
+ Specify an alternate file in which to store the process ID.
  .El
  .Pp
  Upon execution,
Index: inetd.c
===================================================================
RCS file: /cvs/freebsd/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.12
diff -c -r1.12 inetd.c
*** 1.12	1996/07/17 15:00:28
--- inetd.c	1996/08/06 19:29:15
***************
*** 143,148 ****
--- 143,149 ----
  int	toomany = TOOMANY;
  struct	servent *sp;
  struct	rpcent *rpc;
+ struct	in_addr bind_address;
  
  struct	servtab {
  	char	*se_service;		/* name of service */
***************
*** 238,243 ****
--- 239,245 ----
  
  #define NUMINT	(sizeof(intab) / sizeof(struct inent))
  char	*CONFIG = _PATH_INETDCONF;
+ char	*pid_file = _PATH_INETDPID;
  
  #ifdef OLD_SETPROCTITLE
  char	**Argv;
***************
*** 270,276 ****
  
  	openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
  
! 	while ((ch = getopt(argc, argv, "dlR:")) != EOF)
  		switch(ch) {
  		case 'd':
  			debug = 1;
--- 272,279 ----
  
  	openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
  
! 	bind_address.s_addr = htonl(INADDR_ANY);
! 	while ((ch = getopt(argc, argv, "dlR:a:p:")) != EOF)
  		switch(ch) {
  		case 'd':
  			debug = 1;
***************
*** 291,300 ****
  				toomany = tmpint;
  			break;
  		}
  		case '?':
  		default:
  			syslog(LOG_ERR,
! 				"usage: inetd [-dl] [-R rate] [conf-file]");
  			exit(1);
  		}
  	argc -= optind;
--- 294,314 ----
  				toomany = tmpint;
  			break;
  		}
+ 		case 'a':
+ 			if (!inet_aton(optarg, &bind_address)) {
+ 				syslog(LOG_ERR,
+ 			         "-a %s: invalid IP address", optarg);
+ 				 exit(1);
+ 			}
+ 			break;
+ 		case 'p':
+ 			pid_file = optarg;
+ 			break;
  		case '?':
  		default:
  			syslog(LOG_ERR,
! 				"usage: inetd [-dl] [-a address] [-R rate]"
! 				" [-p pidfile] [conf-file]");
  			exit(1);
  		}
  	argc -= optind;
***************
*** 317,328 ****
  			/* no big deal if it fails.. */
  		}
  		pid = getpid();
! 		fp = fopen(_PATH_INETDPID, "w");
  		if (fp) {
  			fprintf(fp, "%ld\n", (long)pid);
  			fclose(fp);
  		} else {
! 			syslog(LOG_WARNING, _PATH_INETDPID ": %m");
  		}
  	}
  	memset(&sv, 0, sizeof(sv));
--- 331,342 ----
  			/* no big deal if it fails.. */
  		}
  		pid = getpid();
! 		fp = fopen(pid_file, "w");
  		if (fp) {
  			fprintf(fp, "%ld\n", (long)pid);
  			fclose(fp);
  		} else {
! 			syslog(LOG_WARNING, "%s: %m", pid_file);
  		}
  	}
  	memset(&sv, 0, sizeof(sv));
***************
*** 918,924 ****
  			sep->se_rpc_lowvers = 0;
                  sep->se_ctrladdr.sin_family = AF_INET;
                  sep->se_ctrladdr.sin_port = 0;
!                 sep->se_ctrladdr.sin_addr.s_addr = htonl(INADDR_ANY);
                  if ((versp = rindex(sep->se_service, '/'))) {
                          *versp++ = '\0';
                          switch (sscanf(versp, "%d-%d",
--- 932,938 ----
  			sep->se_rpc_lowvers = 0;
                  sep->se_ctrladdr.sin_family = AF_INET;
                  sep->se_ctrladdr.sin_port = 0;
!                 sep->se_ctrladdr.sin_addr = bind_address;
                  if ((versp = rindex(sep->se_service, '/'))) {
                          *versp++ = '\0';
                          switch (sscanf(versp, "%d-%d",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608061954.MAA12611>