when rsync is called with -4 or -6, pass that on to ssh [PATCH]

Paul Slootman paul+rsync at wurtel.net
Tue Mar 4 18:07:07 GMT 2008


If rsync is called with -4 or -6, that option is currently ignored when
ssh is used as the transport.  The attached patch is a stab at passing
the option on to the ssh process. It checks that the remote shell
program is something that looks like ssh. Perhaps that could be done
cleaner...


Paul Slootman

--- a/main.c	2008-03-01 21:01:41.000000000 +0100
+++ b/main.c	2008-03-04 18:55:10.933488013 +0100
@@ -82,6 +82,7 @@
 #ifdef ICONV_OPTION
 extern iconv_t ic_send;
 #endif
+extern int default_af_hint;
 
 uid_t our_uid;
 int local_server = 0;
@@ -381,6 +382,23 @@
 			*t++ = '\0';
 		}
 
+#ifdef AF_INET
+                if (default_af_hint == AF_INET) {
+                    if (strncmp(cmd, "ssh", 3) == 0 || strstr(cmd, "/ssh") != NULL) {
+                        /* we're using ssh so we can add a -4 option */
+                        args[argc++] = "-4";
+                    }
+                }
+#endif
+#ifdef AF_INET6
+                if (default_af_hint == AF_INET6) {
+                    if (strncmp(cmd, "ssh", 3) == 0 || strstr(cmd, "/ssh") != NULL) {
+                        /* we're using ssh so we can add a -6 option */
+                        args[argc++] = "-6";
+                    }
+                }
+#endif
+
 		/* check to see if we've already been given '-l user' in
 		 * the remote-shell command */
 		for (i = 0; i < argc-1; i++) {


More information about the rsync mailing list