X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/b2ef4f6134d06b7dbf15b8b3589e021e1333674b..d051056f921f465c487a85f9fa29a2324332bc4b:/clientname.c diff --git a/clientname.c b/clientname.c index 60e8af0a..6d70827c 100644 --- a/clientname.c +++ b/clientname.c @@ -34,7 +34,6 @@ #include "rsync.h" static const char default_name[] = "UNKNOWN"; -extern int am_daemon; extern int am_server; @@ -122,7 +121,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; } @@ -145,8 +144,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,7 +167,7 @@ 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); } @@ -189,7 +188,7 @@ void client_sockaddr(int fd, memset(sin, 0, sizeof *sin); sin->sin_family = AF_INET; *ss_len = sizeof (struct sockaddr_in); -#if HAVE_SOCKADDR_IN_LEN +#ifdef HAVE_SOCKADDR_IN_LEN sin->sin_len = *ss_len; #endif sin->sin_port = sin6.sin6_port; @@ -223,9 +222,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 +244,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; } @@ -271,8 +268,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; } @@ -318,14 +314,12 @@ 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; } - /* Given all these results, we expect that one of them will be * the same as ss. The comparison is a bit complicated. */ for (res = res0; res; res = res->ai_next) { @@ -336,23 +330,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; } -