Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.sbin/inetd pullup the following (approved by releng...



details:   https://anonhg.NetBSD.org/src/rev/116b7848641b
branches:  netbsd-1-5
changeset: 488491:116b7848641b
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Jul 13 05:53:23 2000 +0000

description:
pullup the following (approved by releng-1-5)
        1.64 -> 1.65, 1.66 -> 1.69

----------------------------
1.68 -> 1.69
permit square-bracket notation (as in RFC2732) for the first element
in inetd.conf.  otherwise, we'll have (minor) problem putting IPv6 address in.
sync with kame.

[::1]:ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -ll
----------------------------
1.67 -> 1.68
explicitly check if the address family is supported, by using socket(2).
----------------------------
1.66 -> 1.67
more change on getaddrinfo error handling.

XXX enami, I admit it is not a good thing to check the error code from
getaddrinfo.  it is sometimes mandatory, however.  gai_strerror message
can be too generic in some cases.  we can't really extend getaddrinfo,
as it was not invented by kame (see RFC2553)
----------------------------
1.64 -> 1.65
emit more friendly message on nonexistent service name.
From: enami

diffstat:

 usr.sbin/inetd/inetd.c |  38 +++++++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 13 deletions(-)

diffs (78 lines):

diff -r c52ebffb24ab -r 116b7848641b usr.sbin/inetd/inetd.c
--- a/usr.sbin/inetd/inetd.c    Thu Jul 13 05:51:20 2000 +0000
+++ b/usr.sbin/inetd/inetd.c    Thu Jul 13 05:53:23 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inetd.c,v 1.62.2.2 2000/07/04 00:57:24 thorpej Exp $   */
+/*     $NetBSD: inetd.c,v 1.62.2.3 2000/07/13 05:53:23 itojun Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
 #if 0
 static char sccsid[] = "@(#)inetd.c    8.4 (Berkeley) 4/13/94";
 #else
-__RCSID("$NetBSD: inetd.c,v 1.62.2.2 2000/07/04 00:57:24 thorpej Exp $");
+__RCSID("$NetBSD: inetd.c,v 1.62.2.3 2000/07/13 05:53:23 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -869,14 +869,27 @@
                        struct addrinfo hints, *res;
                        char *host, *port;
                        int error;
+                       int s;
+
+                       /* check if the family is supported */
+                       s = socket(sep->se_family, SOCK_DGRAM, 0);
+                       if (s < 0) {
+                               syslog(LOG_WARNING,
+"%s/%s: %s: the address family is not supported by the kernel",
+                                   sep->se_service, sep->se_proto,
+                                   sep->se_hostaddr);
+                               sep->se_checked = 0;
+                               continue;
+                       }
+                       close(s);
 
                        memset(&hints, 0, sizeof(hints));
                        hints.ai_family = sep->se_family;
                        hints.ai_socktype = sep->se_socktype;
-                       if (!strcmp(sep->se_hostaddr, "*")) {
-                               hints.ai_flags = AI_PASSIVE;
+                       hints.ai_flags = AI_PASSIVE;
+                       if (!strcmp(sep->se_hostaddr, "*"))
                                host = NULL;
-                       } else
+                       else
                                host = sep->se_hostaddr;
                        if (isrpcservice(sep) || ISMUX(sep))
                                port = "0";
@@ -884,12 +897,11 @@
                                port = sep->se_service;
                        error = getaddrinfo(host, port, &hints, &res);
                        if (error) {
-                               if (host == NULL) {
-                                       syslog(LOG_WARNING, "%s/%s: %s: "
-                                           "the address family is not "
-                                           "supported by the kernel",
-                                           sep->se_service, sep->se_proto,
-                                           sep->se_hostaddr);
+                               if (error == EAI_SERVICE) {
+                                       /* gai_strerror not friendly enough */
+                                       syslog(LOG_WARNING, "%s/%s: "
+                                           "unknown service",
+                                           sep->se_service, sep->se_proto);
                                } else {
                                        syslog(LOG_ERR, "%s/%s: %s: %s",
                                            sep->se_service, sep->se_proto,
@@ -1063,8 +1075,8 @@
                syslog(LOG_ERR, "setsockopt (SO_RCVBUF %d): %m",
                    sep->se_rcvbuf);
 #ifdef IPSEC
-       if (ipsecsetup(sep->se_family, sep->se_fd, sep->se_policy) < 0
-        && sep->se_policy) {
+       if (ipsecsetup(sep->se_family, sep->se_fd, sep->se_policy) < 0 &&
+           sep->se_policy) {
                syslog(LOG_ERR, "%s/%s: ipsec setup failed",
                    sep->se_service, sep->se_proto);
                (void)close(sep->se_fd);



Home | Main Index | Thread Index | Old Index