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

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