X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/b2ef4f6134d06b7dbf15b8b3589e021e1333674b..4875d6b64dd0ed8d451746cc0cc609cff36192bd:/clientname.c diff --git a/clientname.c b/clientname.c index 60e8af0a..ed8e97fd 100644 --- a/clientname.c +++ b/clientname.c @@ -122,7 +122,7 @@ char *client_name(int fd) hint.ai_socktype = SOCK_STREAM; if ((err = getaddrinfo(addr, NULL, &hint, &answer)) != 0) { - rprintf(FERROR, RSYNC_NAME ": malformed address %s: %s\n", + rprintf(FLOG, "malformed address %s: %s\n", addr, gai_strerror(err)); return name_buf; } @@ -132,7 +132,7 @@ char *client_name(int fd) ss_len = sizeof (struct sockaddr_in); memcpy(&ss, answer->ai_addr, ss_len); break; -#ifdef INET6 +#if INET6 case AF_INET6: ss_len = sizeof (struct sockaddr_in6); memcpy(&ss, answer->ai_addr, ss_len); @@ -145,8 +145,8 @@ char *client_name(int fd) client_sockaddr(fd, &ss, &ss_len); } - if (!lookup_name(fd, &ss, ss_len, name_buf, sizeof name_buf, - port_buf, sizeof port_buf)) + if (lookup_name(fd, &ss, ss_len, name_buf, sizeof name_buf, + port_buf, sizeof port_buf) == 0) check_name(fd, &ss, name_buf); return name_buf; @@ -168,11 +168,11 @@ void client_sockaddr(int fd, if (getpeername(fd, (struct sockaddr *) ss, ss_len)) { /* FIXME: Can we really not continue? */ - rsyserr(FERROR, errno, "getpeername on fd%d failed", fd); + rsyserr(FLOG, errno, "getpeername on fd%d failed", fd); exit_cleanup(RERR_SOCKETIO); } -#ifdef INET6 +#if INET6 if (get_sockaddr_family(ss) == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)ss)->sin6_addr)) { /* OK, so ss is in the IPv6 family, but it is really @@ -223,9 +223,8 @@ int lookup_name(int fd, const struct sockaddr_storage *ss, NI_NAMEREQD | NI_NUMERICSERV); if (name_err != 0) { strcpy(name_buf, default_name); - rprintf(FERROR, RSYNC_NAME ": name lookup failed for %s: %s\n", - client_addr(fd), - gai_strerror(name_err)); + rprintf(FLOG, "name lookup failed for %s: %s\n", + client_addr(fd), gai_strerror(name_err)); return name_err; } @@ -246,8 +245,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, const char fn[] = "compare_addrinfo_sockaddr"; if (ai->ai_family != ss_family) { - rprintf(FERROR, - "%s: response family %d != %d\n", + rprintf(FLOG, "%s: response family %d != %d\n", fn, ai->ai_family, ss_family); return 1; } @@ -263,7 +261,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sizeof sin1->sin_addr); } -#ifdef INET6 +#if INET6 if (ss_family == AF_INET6) { const struct sockaddr_in6 *sin1, *sin2; @@ -271,8 +269,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sin2 = (const struct sockaddr_in6 *) ai->ai_addr; if (ai->ai_addrlen < sizeof (struct sockaddr_in6)) { - rprintf(FERROR, - "%s: too short sockaddr_in6; length=%d\n", + rprintf(FLOG, "%s: too short sockaddr_in6; length=%d\n", fn, ai->ai_addrlen); return 1; } @@ -281,7 +278,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sizeof sin1->sin6_addr)) return 1; -#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID +#if HAVE_SOCKADDR_IN6_SCOPE_ID if (sin1->sin6_scope_id != sin2->sin6_scope_id) return 1; #endif @@ -318,8 +315,7 @@ int check_name(int fd, hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(name_buf, NULL, &hints, &res0); if (error) { - rprintf(FERROR, - RSYNC_NAME ": forward name lookup for %s failed: %s\n", + rprintf(FLOG, "forward name lookup for %s failed: %s\n", name_buf, gai_strerror(error)); strcpy(name_buf, default_name); return error; @@ -336,23 +332,17 @@ int check_name(int fd, if (!res0) { /* We hit the end of the list without finding an * address that was the same as ss. */ - rprintf(FERROR, RSYNC_NAME - ": no known address for \"%s\": " - "spoofed address?\n", - name_buf); + rprintf(FLOG, "no known address for \"%s\": " + "spoofed address?\n", name_buf); strcpy(name_buf, default_name); } else if (res == NULL) { /* We hit the end of the list without finding an * address that was the same as ss. */ - rprintf(FERROR, RSYNC_NAME - ": %s is not a known address for \"%s\": " - "spoofed address?\n", - client_addr(fd), - name_buf); + rprintf(FLOG, "%s is not a known address for \"%s\": " + "spoofed address?\n", client_addr(fd), name_buf); strcpy(name_buf, default_name); } freeaddrinfo(res0); return 0; } -