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

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