tcp_wrappers/tcp_wrappers-7.6-220015.patch
Tomas Janousek 38552a4257 - dropped the hostname resolving patch
- resolve the address given to hosts_ctl to hostname, if hostname not given
- compare localhost and localhost.localdomain as the same
- fixed a few compile warnings
2007-06-28 13:46:33 +00:00

86 lines
2.5 KiB
Diff

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