Blame SOURCES/tcp_wrappers-7.6-220015.patch

c863fc
diff -up tcp_wrappers_7.6/hosts_ctl.c.patch17 tcp_wrappers_7.6/hosts_ctl.c
c863fc
--- tcp_wrappers_7.6/hosts_ctl.c.patch17	1994-12-28 17:42:28.000000000 +0100
c863fc
+++ tcp_wrappers_7.6/hosts_ctl.c	2008-08-29 09:45:12.000000000 +0200
c863fc
@@ -29,10 +29,12 @@ char   *user;
c863fc
 {
c863fc
     struct request_info request;
c863fc
 
c863fc
-    return (hosts_access(request_init(&request,
c863fc
-				      RQ_DAEMON, daemon,
c863fc
-				      RQ_CLIENT_NAME, name,
c863fc
-				      RQ_CLIENT_ADDR, addr,
c863fc
-				      RQ_USER, user,
c863fc
-				      0)));
c863fc
+    request_init(&request, RQ_DAEMON, daemon,
c863fc
+			   RQ_CLIENT_NAME, name,
c863fc
+			   RQ_CLIENT_ADDR, addr,
c863fc
+			   RQ_USER, user,
c863fc
+			   0);
c863fc
+    sock_hostnofd(&request);
c863fc
+
c863fc
+    return (hosts_access(&request));
c863fc
 }
c863fc
diff -up tcp_wrappers_7.6/socket.c.patch17 tcp_wrappers_7.6/socket.c
c863fc
--- tcp_wrappers_7.6/socket.c.patch17	2008-08-29 09:45:12.000000000 +0200
c863fc
+++ tcp_wrappers_7.6/socket.c	2008-08-29 09:45:12.000000000 +0200
c863fc
@@ -130,6 +130,51 @@ struct request_info *request;
c863fc
     request->server->sin = &server;
c863fc
 }
c863fc
 
c863fc
+/* sock_hostnofd - look up endpoint addresses and install conversion methods */
c863fc
+
c863fc
+void    sock_hostnofd(request)
c863fc
+struct request_info *request;
c863fc
+{
c863fc
+    static struct sockaddr_storage client;
c863fc
+    struct addrinfo hints, *res;
c863fc
+    int     ret;
c863fc
+    char    *host;
c863fc
+
c863fc
+    /* If the address field is non-empty and non-unknown and if the hostname
c863fc
+     * field is empty or unknown, use the address field to get the sockaddr
c863fc
+     * and hostname. */
c863fc
+    if (strlen(request->client->addr) &&
c863fc
+	    HOSTNAME_KNOWN(request->client->addr) &&
c863fc
+	    (!strlen(request->client->name) ||
c863fc
+		!HOSTNAME_KNOWN(request->client->name)))
c863fc
+	host = request->client->addr;
c863fc
+    else
c863fc
+	return;
c863fc
+
c863fc
+    memset(&hints, 0, sizeof(hints));
c863fc
+    hints.ai_family = AF_INET6;
c863fc
+    hints.ai_socktype = SOCK_STREAM;
c863fc
+    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
c863fc
+
c863fc
+    ret = getaddrinfo(host, NULL, &hints, &res;;
c863fc
+    if (ret != 0) {
c863fc
+	hints.ai_family = AF_INET;
c863fc
+	ret = getaddrinfo(host, NULL, &hints, &res;;
c863fc
+    }
c863fc
+
c863fc
+    if (ret != 0) {
c863fc
+	tcpd_warn("can't resolve hostname (%s): %s", host, gai_strerror(ret));
c863fc
+    } else {
c863fc
+	sock_methods(request);
c863fc
+
c863fc
+	memcpy(&client, res->ai_addr, res->ai_addrlen);
c863fc
+	request->client->sin = (struct sockaddr *)&client;
c863fc
+	freeaddrinfo(res);
c863fc
+
c863fc
+	request->client->name[0] = 0;
c863fc
+    }
c863fc
+}
c863fc
+
c863fc
 /* sock_hostaddr - map endpoint address to printable form */
c863fc
 
c863fc
 void    sock_hostaddr(host)
c863fc
diff -up tcp_wrappers_7.6/tcpd.h.patch17 tcp_wrappers_7.6/tcpd.h
c863fc
--- tcp_wrappers_7.6/tcpd.h.patch17	2008-08-29 09:45:12.000000000 +0200
c863fc
+++ tcp_wrappers_7.6/tcpd.h	2008-08-29 09:45:12.000000000 +0200
c863fc
@@ -167,6 +167,7 @@ extern char *eval_server __P((struct req
c863fc
 
c863fc
 /* look up endpoint addresses */
c863fc
 extern void sock_host __P((struct request_info *));
c863fc
+extern void sock_hostnofd __P((struct request_info *));
c863fc
 /* translate address to hostname */
c863fc
 extern void sock_hostname __P((struct host_info *));
c863fc
 /* address to printable address */