]> git.pld-linux.org Git - packages/tcp_wrappers.git/blob - tcp_wrappers-220015.patch
- rediffed
[packages/tcp_wrappers.git] / tcp_wrappers-220015.patch
1 - resolve hostnames in hosts.{allow,deny}, should fix a bunch of issues with IPv4/6
2 --- tcp_wrappers_7.6/tcpd.h.220015      2007-06-28 15:42:49.000000000 +0200
3 +++ tcp_wrappers_7.6/tcpd.h     2007-06-28 15:43:59.000000000 +0200
4 @@ -167,6 +167,7 @@
5  
6  /* look up endpoint addresses */
7  extern void sock_host __P((struct request_info *));
8 +extern void sock_hostnofd __P((struct request_info *));
9  /* translate address to hostname */
10  extern void sock_hostname __P((struct host_info *));
11  /* address to printable address */
12 --- tcp_wrappers_7.6/hosts_ctl.c.220015 1994-12-28 17:42:28.000000000 +0100
13 +++ tcp_wrappers_7.6/hosts_ctl.c        2007-06-28 15:42:49.000000000 +0200
14 @@ -29,10 +29,12 @@
15  {
16      struct request_info request;
17  
18 -    return (hosts_access(request_init(&request,
19 -                                     RQ_DAEMON, daemon,
20 -                                     RQ_CLIENT_NAME, name,
21 -                                     RQ_CLIENT_ADDR, addr,
22 -                                     RQ_USER, user,
23 -                                     0)));
24 +    request_init(&request, RQ_DAEMON, daemon,
25 +                          RQ_CLIENT_NAME, name,
26 +                          RQ_CLIENT_ADDR, addr,
27 +                          RQ_USER, user,
28 +                          0);
29 +    sock_hostnofd(&request);
30 +
31 +    return (hosts_access(&request));
32  }
33 --- tcp_wrappers_7.6/socket.c.220015    2007-06-28 15:42:49.000000000 +0200
34 +++ tcp_wrappers_7.6/socket.c   2007-06-28 15:42:49.000000000 +0200
35 @@ -147,6 +147,51 @@
36  #endif
37  }
38  
39 +/* sock_hostnofd - look up endpoint addresses and install conversion methods */
40 +
41 +void    sock_hostnofd(request)
42 +struct request_info *request;
43 +{
44 +    static struct sockaddr_storage client;
45 +    struct addrinfo hints, *res;
46 +    int     ret;
47 +    char    *host;
48 +
49 +    /* If the address field is non-empty and non-unknown and if the hostname
50 +     * field is empty or unknown, use the address field to get the sockaddr
51 +     * and hostname. */
52 +    if (strlen(request->client->addr) &&
53 +           HOSTNAME_KNOWN(request->client->addr) &&
54 +           (!strlen(request->client->addr) ||
55 +               !HOSTNAME_KNOWN(request->client->name)))
56 +       host = request->client->addr;
57 +    else
58 +       return;
59 +
60 +    memset(&hints, 0, sizeof(hints));
61 +    hints.ai_family = AF_INET6;
62 +    hints.ai_socktype = SOCK_STREAM;
63 +    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
64 +
65 +    ret = getaddrinfo(host, NULL, &hints, &res);
66 +    if (ret != 0) {
67 +       hints.ai_family = AF_INET;
68 +       ret = getaddrinfo(host, NULL, &hints, &res);
69 +    }
70 +
71 +    if (ret != 0) {
72 +       tcpd_warn("can't resolve hostname (%s): %s", host, gai_strerror(ret));
73 +    } else {
74 +       sock_methods(request);
75 +
76 +       memcpy(&client, res->ai_addr, res->ai_addrlen);
77 +       request->client->sin = (struct sockaddr *)&client;
78 +       freeaddrinfo(res);
79 +
80 +       request->client->name[0] = 0;
81 +    }
82 +}
83 +
84  /* sock_hostaddr - map endpoint address to printable form */
85  
86  void    sock_hostaddr(host)
This page took 0.080665 seconds and 3 git commands to generate.