Blame SOURCES/netkit-ftp-0.17-multihome.patch

09d58c
--- netkit-ftp-0.17/ftp/ftp_var.h.rasold	2006-01-12 11:23:16.000000000 +0100
09d58c
+++ netkit-ftp-0.17/ftp/ftp_var.h	2006-01-12 11:24:06.000000000 +0100
09d58c
@@ -69,6 +69,7 @@
09d58c
 Extern int	bell;		/* ring bell on cmd completion */
09d58c
 Extern int	doglob;		/* glob local file names */
09d58c
 Extern int	autologin;	/* establish user account on connection */
09d58c
+Extern int	multihome;	/* multi homed host, use same interface for cmd and data channels */
09d58c
 Extern int	proxy;		/* proxy server connection active */
09d58c
 Extern int	proxflag;	/* proxy connection exists */
09d58c
 Extern int	sunique;	/* store files on server with unique name */
09d58c
--- netkit-ftp-0.17/ftp/ftp.c.rasold	2006-01-12 11:14:55.000000000 +0100
09d58c
+++ netkit-ftp-0.17/ftp/ftp.c	2006-01-12 11:22:42.000000000 +0100
09d58c
@@ -132,6 +132,7 @@
09d58c
 static sigjmp_buf ptabort;
09d58c
 static int ptabflg = 0;
09d58c
 static int abrtflag = 0;
09d58c
+struct sockaddr_in source;
09d58c
 
09d58c
 void lostpeer(int);
09d58c
 extern int connected;
09d58c
@@ -153,7 +154,7 @@
09d58c
 char *
09d58c
 hookup(const char *host, const char *port)
09d58c
 {
09d58c
-	int s, tos, error;
09d58c
+	int s, tos, error, alen;
09d58c
 	socklen_t len;
09d58c
 	static char hostnamebuf[256];
09d58c
 	struct addrinfo hints, *res, *res0;
09d58c
@@ -278,7 +279,11 @@
09d58c
 	}
09d58c
 	if (verbose)
09d58c
 		printf("Connected to %s (%s).\n", hostname, hbuf);
09d58c
-	if (getreply(0) > 2) { 	/* read startup message from server */
09d58c
+	alen = sizeof(source);
09d58c
+	getsockname(s,(struct sockaddr*)&source, &alen;;
09d58c
+	source.sin_port = 0;    /* We just want the addr, not the port */
09d58c
+
09d58c
+	if (getreply(0) > 2) { 	/* read startup message from server    */
09d58c
 		if (cin)
09d58c
 			(void) fclose(cin);
09d58c
 		if (cout)
09d58c
@@ -1254,6 +1259,13 @@
09d58c
 			perror("ftp: socket");
09d58c
 			return(1);
09d58c
 		}
09d58c
+		if((multihome) &&
09d58c
+			bind(data, (struct sockaddr*)&source, sizeof(source)) == -1) {
09d58c
+			close(data);
09d58c
+			data = -1;
09d58c
+			perror("ftp multihome bind");
09d58c
+			return(1);
09d58c
+                }
09d58c
 		if (options & SO_DEBUG &&
09d58c
 		    setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
09d58c
 			       sizeof (on)) < 0)
09d58c
--- netkit-ftp-0.17/ftp/main.c.rasold	2006-01-12 11:24:27.000000000 +0100
09d58c
+++ netkit-ftp-0.17/ftp/main.c	2006-01-12 11:27:20.000000000 +0100
09d58c
@@ -93,6 +93,7 @@
09d58c
 	printf("\t   -n: inhibit auto-login\n");
09d58c
 	printf("\t   -e: disable readline support, if present\n");
09d58c
 	printf("\t   -g: disable filename globbing\n");
09d58c
+	printf("\t   -m: don't force data channel interface to the same as control channel\n");
09d58c
 	printf("\t   -v: verbose mode\n");
09d58c
 	printf("\t   -t: enable packet tracing [nonfunctional]\n");
09d58c
 	printf("\t   -d: enable debugging\n");
09d58c
@@ -120,6 +121,7 @@
09d58c
 	doglob = 1;
09d58c
 	interactive = 1;
09d58c
 	autologin = 1;
09d58c
+	multihome = 1;
09d58c
 	passivemode = 1;
09d58c
 
09d58c
         cp = strrchr(argv[0], '/');
09d58c
@@ -172,6 +174,10 @@
09d58c
 				rl_inhibit = 1;
09d58c
 				break;
09d58c
 				
09d58c
+			case 'm':
09d58c
+				multihome = 0;
09d58c
+				break;
09d58c
+
09d58c
 			case 'h':
09d58c
 				usage();
09d58c
 				exit(0);
09d58c
--- netkit-ftp-0.17/ftp/ftp.1.rasold	2006-01-12 11:14:09.000000000 +0100
09d58c
+++ netkit-ftp-0.17/ftp/ftp.1	2006-01-12 11:15:48.000000000 +0100
09d58c
@@ -92,6 +92,10 @@
09d58c
 executable. Otherwise, does nothing.
09d58c
 .It Fl g
09d58c
 Disables file name globbing.
09d58c
+.It Fl m
09d58c
+The default requires that ftp explicitly binds to the same interface for the data
09d58c
+channel as the control channel in passive mode. Useful on multi-homed
09d58c
+clients. This option disables this behavior.
09d58c
 .It Fl v
09d58c
 Verbose option forces
09d58c
 .Nm ftp