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