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

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