1 This patch adds a forward lookup of any hostnames listed in the
2 "hosts allow" or "hosts deny" daemon config options. Based on
3 a patch by Paul Williamson.
5 To use this patch, run these commands for a successful build:
7 patch -p1 <patches/daemon-forward-lookup.diff
8 ./configure (optional if already run)
11 diff --git a/access.c b/access.c
14 @@ -210,6 +210,43 @@ static int match_address(char *addr, char *tok)
18 +static int match_hostlookup(char *addr, char *tok)
21 + unsigned int i, len;
25 + if ((p = strchr(tok,'/')) != NULL) {
31 + /* Fail quietly if tok is an address (not a hostname) */
32 + failed = strspn(tok, ".0123456789") == len;
34 + failed ||= strchr(tok, ':') != NULL;
37 + if (!failed && (hp = gethostbyname(tok)) == NULL)
46 + for (i = 0; hp->h_addr_list[i] != NULL; i++) {
47 + tok = inet_ntoa(*(struct in_addr*)(hp->h_addr_list[i]));
48 + if (match_address(addr, tok))
55 static int access_match(char *list, char *addr, char *host)
58 @@ -223,7 +260,7 @@ static int access_match(char *list, char *addr, char *host)
61 for (tok = strtok(list2, " ,\t"); tok; tok = strtok(NULL, " ,\t")) {
62 - if (match_hostname(host, tok) || match_address(addr, tok)) {
63 + if (match_hostname(host, tok) || match_address(addr, tok) || match_hostlookup(addr, tok)) {