inetd needs "discard" service in /etc/services
Hajimu UMEMOTO
ume at FreeBSD.org
Tue Mar 23 09:20:37 PST 2004
Hi,
>>>>> On Fri, 12 Mar 2004 09:06:30 -0800
>>>>> Brooks Davis <brooks at 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 at mahoroba.org ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/
More information about the freebsd-hackers
mailing list