X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/f2863bc00ee660400c314a756d19ce5455dce87d..c1ff70aa47e11c5b37634479a0facee775a7b6d9:/daemon-forward-lookup.diff diff --git a/daemon-forward-lookup.diff b/daemon-forward-lookup.diff index a10df18..dbaf43c 100644 --- a/daemon-forward-lookup.diff +++ b/daemon-forward-lookup.diff @@ -8,39 +8,35 @@ To use this patch, run these commands for a successful build: ./configure (optional if already run) make +based-on: a01e3b490eb36ccf9e704840e1b6683dab867550 diff --git a/access.c b/access.c --- a/access.c +++ b/access.c -@@ -210,6 +210,43 @@ static int match_address(char *addr, char *tok) +@@ -210,6 +210,38 @@ static int match_address(const char *addr, const char *tok) return ret; } -+static int match_hostlookup(char *addr, char *tok) ++static int match_hostlookup(const char *addr, const char *tok) +{ -+ struct hostent *hp; ++ struct hostent *hp = NULL; + unsigned int i, len; -+ int failed; -+ char *p; ++ const char *p; + -+ if ((p = strchr(tok,'/')) != NULL) { -+ *p = '\0'; ++ if ((p = strchr(tok,'/')) != NULL) + len = p - tok; -+ } else ++ else + len = strlen(tok); + -+ /* Fail quietly if tok is an address (not a hostname) */ -+ failed = strspn(tok, ".0123456789") == len; ++ /* Fail quietly (hp left NULL) if tok is an address, not a hostname. */ +#ifdef INET6 -+ failed ||= strchr(tok, ':') != NULL; ++ if (strcspn(tok, ":/") != len) { ++ ; ++ } else +#endif ++ if (strspn(tok, ".0123456789") != len) ++ hp = gethostbyname(tok); + -+ if (!failed && (hp = gethostbyname(tok)) == NULL) -+ failed = 1; -+ -+ if (p) -+ *p = '/'; -+ -+ if (failed) ++ if (!hp) + return 0; + + for (i = 0; hp->h_addr_list[i] != NULL; i++) { @@ -52,11 +48,11 @@ diff --git a/access.c b/access.c + return 0; +} + - static int access_match(char *list, char *addr, char *host) + static int access_match(const char *list, const char *addr, const char *host) { char *tok; -@@ -223,7 +260,7 @@ static int access_match(char *list, char *addr, char *host) - strlower(host); +@@ -221,7 +253,7 @@ static int access_match(const char *list, const char *addr, const char *host) + strlower(list2); for (tok = strtok(list2, " ,\t"); tok; tok = strtok(NULL, " ,\t")) { - if (match_hostname(host, tok) || match_address(addr, tok)) {