ipv6 support in ftp module



Hi,

Currently there is no IPv6 support in the ftp module[1]. It's quite
annoying.

I've made quick patch that works. The patch add a gconf key to use the
old behaviour.

The problem is that there still some protocol specific code
(sockaddr_in and so on) in the kerberos code I cannot deal with.

Could you give me a more informations about the best way to solve this
problem

Regards

Laurent

[1] http://bugzilla.gnome.org/show_bug.cgi?id=157457
Index: modules/ftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/ftp-method.c,v
retrieving revision 1.129
diff -u -p -r1.129 ftp-method.c
--- modules/ftp-method.c	28 Sep 2006 17:40:17 -0000	1.129
+++ modules/ftp-method.c	19 Dec 2006 14:39:17 -0000
@@ -151,6 +151,7 @@ static const char USE_PROXY_KEY[] = "/sy
 static const char PROXY_FTP_HOST_KEY[] = "/system/proxy/ftp_host";
 static const char PROXY_FTP_PORT_KEY[] = "/system/proxy/ftp_port";
 
+static const char FTP_USE_OLD_PASV_KEY[] = "/system/ftp/use_old_pasv";
 
 static GnomeVFSResult do_open	         (GnomeVFSMethod               *method,
 					  GnomeVFSMethodHandle         **method_handle,
@@ -189,6 +190,9 @@ static const int   control_port = 21;
 static gchar *proxy_host = NULL;
 static int proxy_port = 0;
 
+/* Old PASV command */
+static gboolean old_pasv = FALSE;
+
 /* A GHashTable of FtpConnectionPool */
 
 static GHashTable *connection_pools = NULL;
@@ -685,31 +689,55 @@ do_transfer_command (FtpConnection *conn
 	}
 
 	/* FIXME bugzilla.eazel.com 1464: implement non-PASV mode */
+	if (!old_pasv) {
+		/* send EPSV RFC 2428*/
+		result = do_basic_command (conn, "EPSV", cancellation);
 
-	/* send PASV */
-	result = do_basic_command (conn, "PASV", cancellation);
-	
-	if (result != GNOME_VFS_OK) {
-		return result;
-	}
+		if (result != GNOME_VFS_OK) {
+			return result;
+		}
+		
+		host = g_strdup (conn->pool->ip);
+
+		{
+			gchar *ptr, *response = g_strdup (conn->response_message);
+			ptr = strchr (response, '(');
+			   if (!ptr ||
+			       (sscanf (ptr+1,"|||%d|",&port) != 1)) {
+				g_free (response);
+				return GNOME_VFS_ERROR_CORRUPTED_DATA;
+			}
 
-	/* parse response */
-	{
-	        gint a1, a2, a3, a4, p1, p2;
-		gchar *ptr, *response = g_strdup (conn->response_message);
-		ptr = strchr (response, '(');
-		if (!ptr ||
-		    (sscanf (ptr+1,"%d,%d,%d,%d,%d,%d", &a1, &a2, &a3, 
-			     &a4, &p1, &p2) != 6)) {
 			g_free (response);
-			return GNOME_VFS_ERROR_CORRUPTED_DATA;
+
+		}
+	}
+	else {
+		/* send PASV */
+		result = do_basic_command (conn, "PASV", cancellation);
+		
+		if (result != GNOME_VFS_OK) {
+			return result;
 		}
 
-		host = g_strdup_printf ("%d.%d.%d.%d", a1, a2, a3, a4);
-		port = p1*256 + p2;
+		/* parse response */
+		{
+			gint a1, a2, a3, a4, p1, p2;
+			gchar *ptr, *response = g_strdup (conn->response_message);
+			ptr = strchr (response, '(');
+			if (!ptr ||
+			    (sscanf (ptr+1,"%d,%d,%d,%d,%d,%d", &a1, &a2, &a3, 
+				     &a4, &p1, &p2) != 6)) {
+				g_free (response);
+				return GNOME_VFS_ERROR_CORRUPTED_DATA;
+			}
+
+			host = g_strdup_printf ("%d.%d.%d.%d", a1, a2, a3, a4);
+			port = p1*256 + p2;
 
-		g_free (response);
+			g_free (response);
 
+		}
 	}
 
 	/* connect */
@@ -3002,6 +3030,8 @@ vfs_module_init (const char *method_name
 							   PROXY_FTP_PORT_KEY,
 							   NULL);
 		} else proxy_host = NULL;
+
+		old_pasv = gconf_client_get_bool (gclient, FTP_USE_OLD_PASV_KEY, NULL);
 	}
 
 	return &method;

Attachment: pgpBXkeoFb2lS.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]