Unhelpful error message when matching hosts in access list [PATCH]

Thorild Selen thorild at Update.UU.SE
Tue Jul 8 02:29:58 EST 2003

> Ah yes, I recall thinking that your patch should go in, but I thereafter
> forgot about it.  I've gone ahead and committed your change since it was
> very simple and similar to what we used to do in 2.5.5, only with a
> better heuristic.  I'm planning to look into Thorild Selen's patch as--text follows this line--
> well (to see if it is still needed), but I haven't had a chance yet.

It's not enough just checking the last char to see whether something
is an address:

* The letters a-f are valid last characters of hostnames as well as of
  IPv6 addresses. Just testing the last char is not enough, at least
  not in this case.

* A machine name may possibly end with a digit. Perhaps not likely on
  _the_ internet if we assume it to be an FQDN, but maybe on a private
  network, for example.

Alternative heuristics:

* If the string contains a colon, then it's an address. (IPv6)

* Otherwise, it's an address only if it consists of nothing but dots
  and digits. (IPv4)

* Otherwise, it can't be an address.

This can simply be implemented as:

  /* Fail quietly if tok is a hostname (not an address) */
  if (! (strchr(tok, ':')                                 /* IPv6 */
         || (strspn(tok, ".0123456789") == strlen(tok)))) /* IPv4 */
    return 0;

(What to do when rsync is configured for IPv4 only, but we are given
an IPv6 address to match against? Just considering it a failed match
would perhaps do.)

Also, please consider introducing the other change in my patch;
i.e. replacing

               rprintf(FERROR,"malformed address %s\n", tok);


                       "error matching address %s: %s\n",

in match_address. This gives a more descriptive error message when
getaddrinfo fails, instead of just telling us that it failed.

Thorild Selén
Datorföreningen Update / Update Computer Club, Uppsala, SE

More information about the rsync mailing list