When rsync encountered an empty file list, it behaved differently
[rsync.git] / clientname.c
index 60e8af0a68a6d4208188d110020cdab3b79b4191..270f09f11233099a80c61ce16af981237d4284c4 100644 (file)
@@ -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;
                }
@@ -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,7 +168,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 +189,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 +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;
        }
@@ -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;
                }
@@ -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;
 }
-