noip.c (do_implicit_bind): Report the local address that we chose.
[preload-hacks] / noip.c
diff --git a/noip.c b/noip.c
index fd86cb3..1af5768 100644 (file)
--- a/noip.c
+++ b/noip.c
@@ -985,6 +985,8 @@ static int do_implicit_bind(int sk, const struct sockaddr *sa)
   wildcard_address(sa->sa_family, &addr.sa);
 found:
   encode_inet_addr(&sun, &addr.sa, ENCF_FRESH);
+  D( fprintf(stderr, "noip(%d): implicitly binding to %s\n",
+            pid, sun.sun_path); )
   if (real_bind(sk, SA(&sun), SUN_LEN(&sun))) return (-1);
   return (0);
 }
@@ -1002,6 +1004,11 @@ static int fixup_client_socket(int sk, const struct sockaddr **sa_r,
   socklen_t mylen = sizeof(*sun);
   const struct sockaddr *sa = *sa_r;
 
+  /* If this isn't a Unix-domain socket then there's nothing to do. */
+  if (real_getsockname(sk, SA(sun), &mylen) < 0) return (-1);
+  if (sun->sun_family != AF_UNIX) return (0);
+  if (mylen < sizeof(*sun)) ((char *)sun)[mylen] = 0;
+
   /* If we're allowed to talk to a real remote endpoint, then fix things up
    * as necessary and proceed.
    */
@@ -1010,11 +1017,6 @@ static int fixup_client_socket(int sk, const struct sockaddr **sa_r,
     return (0);
   }
 
-  /* If this isn't a Unix-domain socket then there's nothing to do. */
-  if (real_getsockname(sk, SA(sun), &mylen) < 0) return (-1);
-  if (sun->sun_family != AF_UNIX) return (0);
-  if (mylen < sizeof(*sun)) ((char *)sun)[mylen] = 0;
-
   /* Speaking of which, if we don't have a local address, then we should
    * arrange one now.
    */