Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jun 1999 14:30:02 -0700 (PDT)
From:      Sheldon Hearn <sheldonh@uunet.co.za>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/11796: Bad lines in 3.2-RELEASE inetd.conf
Message-ID:  <199906302130.OAA63476@freefall.freebsd.org>

index | next in thread | raw e-mail

The following reply was made to PR misc/11796; it has been noted by GNATS.

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Alex Charalabidis <alex@wnm.net>
Cc: Dag-Erling Smorgrav <des@flood.ping.uio.no>,
	freebsd-gnats-submit@freebsd.org
Subject: Re: misc/11796: Bad lines in 3.2-RELEASE inetd.conf
Date: Wed, 30 Jun 1999 23:22:40 +0200

 Below is a patch that teaches inetd to match correctly an internal
 service name against any one of the service's canonical name and
 aliases.
 
 It works for me, although it's worth noting that it does _not_ magically
 allow you to start using any old service name in /etc/hosts.allow . The
 name for a service in /etc/hosts.allow must still match the name used to
 configure it in /etc/inetd.conf .
 
 It's for application against CURRENT source.
 
 DES? Wotcha think?
 
 Ciao,
 Sheldon.
 
 PS: The expensive matchservent() isn't called in any long-running loops
     and shold be short-circuited by the || oeprator most of the time.
 
 Index: inetd.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/inetd/inetd.c,v
 retrieving revision 1.54
 diff -u -d -r1.54 inetd.c
 --- inetd.c	1999/06/28 11:27:14	1.54
 +++ inetd.c	1999/06/30 21:14:01
 @@ -253,6 +253,7 @@
  void		ident_stream __P((int, struct servtab *));
  void		machtime_dg __P((int, struct servtab *));
  void		machtime_stream __P((int, struct servtab *));
 +int		matchservent __P((char *, char *, char *));
  char	       *newstr __P((char *));
  char	       *nextline __P((FILE *));
  void		print_service __P((char *, struct servtab *));
 @@ -1395,8 +1396,10 @@
  		struct biltin *bi;
  
  		for (bi = biltins; bi->bi_service; bi++)
 -			if (bi->bi_socktype == sep->se_socktype &&
 -			    strcmp(bi->bi_service, sep->se_service) == 0)
 +			if ((bi->bi_socktype == sep->se_socktype &&
 +			    strcmp(bi->bi_service, sep->se_service) == 0) ||
 +			    matchservent(bi->bi_service, sep->se_service,
 +			    sep->se_proto))
  				break;
  		if (bi->bi_service == 0) {
  			syslog(LOG_ERR, "internal service %s unknown",
 @@ -1544,6 +1547,22 @@
  		return (cp);
  	syslog(LOG_ERR, "strdup: %m");
  	exit(EX_OSERR);
 +}
 +
 +int matchservent(name1, name2, proto)
 +	char *name1, *name2, *proto;
 +{
 +	char **alias;
 +	struct servent *se;
 +
 +	if ((se = getservbyname(name1, proto)) != NULL) {
 +		if (strcmp(name2, se->s_name) == 0)
 +			return(1);
 +		for (alias = se->s_aliases; *alias; alias++)
 +			if (strcmp(name2, *alias) == 0)
 +				return(1);
 +	}
 +	return(0);
  }
  
  #ifdef OLD_SETPROCTITLE
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



home | help

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