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

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