Doc.
[rsync/rsync.git] / socket.c
index 2735317..84d17f5 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -42,7 +42,7 @@ static int lookup_name(const struct sockaddr_storage *ss,
 
 static int check_name(const struct sockaddr_storage *ss,
                      socklen_t ss_len,
-                     const char *name_buf,
+                     char *name_buf,
                      const char *port_buf);
 
 /* Establish a proxy connection on an open socket to a web roxy by
@@ -705,7 +705,7 @@ static int lookup_name(const struct sockaddr_storage *ss,
  * we don't abort the connection but just emit a warning. */
 static int check_name(const struct sockaddr_storage *ss,
                      socklen_t ss_len,
-                     const char *name_buf,
+                     char *name_buf,
                      const char *port_buf)
 {
        struct addrinfo hints, *res, *res0;
@@ -817,16 +817,20 @@ static int socketpair_tcp(int fd[2])
 }
 
 
-/*******************************************************************
-run a program on a local tcp socket, this is used to launch smbd
-when regression testing
-the return value is a socket which is attached to a subprocess
-running "prog". stdin and stdout are attached. stderr is left
-attached to the original stderr
- ******************************************************************/
+
+/**
+ * Run a program on a local tcp socket, so that we can talk to it's
+ * stdin and stdout.  This is used to fake a connection to a daemon
+ * for testing -- not for the normal case of running SSH.
+ *
+ * @return a socket which is attached to a subprocess running
+ * "prog". stdin and stdout are attached. stderr is left attached to
+ * the original stderr
+ **/
 int sock_exec(const char *prog)
 {
        int fd[2];
+       
        if (socketpair_tcp(fd) != 0) {
                rprintf (FERROR, RSYNC_NAME
                         ": socketpair_tcp failed (%s)\n",
@@ -839,10 +843,12 @@ int sock_exec(const char *prog)
                close(1);
                dup(fd[1]);
                dup(fd[1]);
-               if (verbose > 3)
+               if (verbose > 3) {
+                       /* Can't use rprintf because we've forked. */
                        fprintf (stderr,
                                 RSYNC_NAME ": execute socket program \"%s\"\n",
                                 prog);
+               }
                exit (system (prog));
        }
        close (fd[1]);