On Fri, Jan 11, 2002 at 08:14:23AM +0100, Laurent CREPET wrote: > I've just upgraded my rsync server to 2.5.1 (before, I was using 2.4.6), > without changing anything in /etc/rsyncd.conf, and now, I have this logs > each time a client connect to server: > > 2002/01/07 18:33:03 [10432] rsync: reverse name lookup mismatch on fd3 - spoofed >address? > 2002/01/07 18:33:03 [10432] rsync on admin/sbin/padmin_update.sh from UNKNOWN >(172.16.65.14) > 2002/01/07 18:33:03 [10432] wrote 79 bytes read 88 bytes total size 1494 > > The server configuration has not changed since upgrading to rsync 2.5.1. > No noticed network configuration problem.
I'm seeing the same problem on Linux 2.2.18 kernel. Attached are patches against 2.5.1 and the current CVS that fixes it, although I don't know if it the best way. The code was comparing two socket addresses which are apparently not in the same format somehow; I convert them to IP address strings and then compare them. Does anybody have a better way? - Dave Dykstra
--- socket.c.O Fri Jan 11 14:21:10 2002 +++ socket.c Fri Jan 11 14:25:50 2002 @@ -598,6 +598,8 @@ int length = sizeof(ss); static char name_buf[100]; static char port_buf[100]; + char addr_buf[100]; + char *clientaddr; char *def = "UNKNOWN"; static int initialised; struct addrinfo hints, *res, *res0; @@ -659,23 +661,24 @@ return name_buf; } + clientaddr = client_addr(fd); /* XXX sin6_flowinfo and other fields */ for (res = res0; res; res = res->ai_next) { if (res->ai_family != get_sockaddr_family(&ss)) continue; if (res->ai_addrlen != length) continue; - if (memcmp(res->ai_addr, &ss, res->ai_addrlen) == 0) + getnameinfo(res->ai_addr, res->ai_addrlen, + addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST); + if (strcmp(clientaddr, addr_buf) == 0) break; } - /* TODO: Do a forward lookup as well to prevent spoofing */ - if (res == NULL) { + rprintf(FERROR, + "reverse+forward lookup for %s (%s) mismatched - spoofed +address? \n", + clientaddr, name_buf); strcpy(name_buf, def); - rprintf(FERROR, RSYNC_NAME ": " - "reverse name lookup mismatch on fd%d - spoofed address?\n", - fd); } freeaddrinfo(res0);
--- socket.c.O Fri Jan 11 14:18:20 2002 +++ socket.c Fri Jan 11 14:24:28 2002 @@ -603,6 +603,8 @@ int length = sizeof(ss); static char name_buf[100]; static char port_buf[100]; + char addr_buf[100]; + char *clientaddr; char *def = "UNKNOWN"; static int initialised; struct addrinfo hints, *res, *res0; @@ -673,21 +675,24 @@ return name_buf; } + clientaddr = client_addr(fd); /* XXX sin6_flowinfo and other fields */ for (res = res0; res; res = res->ai_next) { if (res->ai_family != get_sockaddr_family(&ss)) continue; if (res->ai_addrlen != length) continue; - if (memcmp(res->ai_addr, &ss, res->ai_addrlen) == 0) + getnameinfo(res->ai_addr, res->ai_addrlen, + addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST); + if (strcmp(clientaddr, addr_buf) == 0) break; } if (res == NULL) { + rprintf(FERROR, + "reverse+forward lookup for %s (%s) mismatched - spoofed +address? \n", + clientaddr, name_buf); strcpy(name_buf, def); - rprintf(FERROR, RSYNC_NAME ": " - "reverse name lookup for \"%s\" failed on fd%d - spoofed address? \n", - name_buf, fd); } freeaddrinfo(res0);