Date: Wed, 24 Mar 2004 02:20:26 +0900 From: Hajimu UMEMOTO <ume@FreeBSD.org> To: Brooks Davis <brooks@one-eyed-alien.net> Cc: dwmalone@freebsd.org Subject: Re: inetd needs "discard" service in /etc/services Message-ID: <ygefzbzzdid.wl%ume@FreeBSD.org> In-Reply-To: <20040312170629.GB7661@Odin.AC.HMC.Edu> References: <20040312010000.GA9949@Odin.AC.HMC.Edu> <200403121051.aa75277@salmon.maths.tcd.ie> <20040312170629.GB7661@Odin.AC.HMC.Edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi,
>>>>> On Fri, 12 Mar 2004 09:06:30 -0800
>>>>> Brooks Davis <brooks@one-eyed-alien.net> said:
brooks> Nope, I tried that. It turns out there's an annoying edge case that
brooks> makes it not work in this case (from line 496):
brooks> * check for special cases. (1) numeric servname is disallowed if
brooks> * socktype/protocol are left unspecified. (2) servname is disallowed
brooks> * for raw and other inet{,6} sockets.
How about this patch?
Index: usr.sbin/inetd/inetd.c
diff -u -p usr.sbin/inetd/inetd.c.orig usr.sbin/inetd/inetd.c
--- usr.sbin/inetd/inetd.c.orig Sat Nov 1 04:39:15 2003
+++ usr.sbin/inetd/inetd.c Tue Mar 23 17:41:17 2004
@@ -403,12 +403,16 @@ main(int argc, char **argv)
* getaddrinfo(). But getaddrinfo() requires at least one of
* hostname or servname is non NULL.
* So when hostname is NULL, set dummy value to servname.
+ * Since getaddrinfo() doesn't accept numeric servname, and
+ * we doesn't use ai_socktype of struct addrinfo returned
+ * from getaddrinfo(), we set dummy value to ai_socktype.
*/
- servname = (hostname == NULL) ? "discard" /* dummy */ : NULL;
+ servname = (hostname == NULL) ? "0" /* dummy */ : NULL;
bzero(&hints, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM; /* dummy */
error = getaddrinfo(hostname, servname, &hints, &res);
if (error != 0) {
syslog(LOG_ERR, "-a %s: %s", hostname, gai_strerror(error));
brooks> The real problem is that we should either not use getaddrinfo to make
brooks> sockaddrs or we should do it on demand when we actually have what we
brooks> need (i.e. a service name and protocol).
It seems NetBSD's inetd do it on demand.
Sincerely,
--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygefzbzzdid.wl%ume>
