[ Patch] Re: Bug in ftp module or in eel ?



This patch fixes the hang with the ftp modules and the ssh module. It also fixes two other bugs in the ssh modules : ssh://localhost didn't work (a username was mandatory, now it uses the current username if it's not specified), and the do_read_directory function expected to get a 'ls' output in the C locale, so it didn't work with systems in other locales. Now it should work. However, I used something like "LC_ALL=C;ls -l" which won't work if the user shell is tcsh iirc. I tried to use bash -c "LC_ALL=C;ls" but it didn't work, so any help is welcome to fix that.

Christophe
? gnome-vfs.diff
? modules.diff
? modules/vfolder
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v
retrieving revision 1.1334.2.40
diff -u -r1.1334.2.40 ChangeLog
--- ChangeLog	23 Aug 2002 21:48:56 -0000	1.1334.2.40
+++ ChangeLog	27 Aug 2002 08:16:49 -0000
@@ -1,3 +1,13 @@
+2002-08-26  Christophe Fergeau  <teuf users sourceforge net>
+	* modules/ssh-method.c: 
+	Make do_read return GNOME_VFS_ERROR_EOF when it read 0 byte
+	Force C locale in ssh_connect before running ssh (the ls parsing 
+	function expects ls output to be in this locale)
+	When the uri contains no username, use the name of the current user
+	(otherwise ssh://localhost won't work).
+	* modules/ftp-method.c:
+	Make do_read return GNOME_VFS_ERROR_EOF when it read 0 byte
+
 === merge in changes from gnome-vfs-2-0-vfolder-rewrite branch ===
 
 2002-08-23  Alex Graveley  <alex ximian com>
Index: modules/ftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/ftp-method.c,v
retrieving revision 1.87
diff -u -r1.87 ftp-method.c
--- modules/ftp-method.c	8 May 2002 19:04:51 -0000	1.87
+++ modules/ftp-method.c	27 Aug 2002 08:16:50 -0000
@@ -860,7 +860,7 @@
 	 GnomeVFSContext *context) 
 {
 	FtpConnection *conn = (FtpConnection * )method_handle;
-
+	GnomeVFSResult result;
 #if 0
 	/*
 	if (conn->operation != FTP_READ) {
@@ -870,7 +870,11 @@
 	g_print ("do_read (%p)\n", method_handle);
 #endif
 
-	return gnome_vfs_iobuf_read (conn->data_iobuf, buffer, num_bytes, bytes_read);
+	result = gnome_vfs_iobuf_read (conn->data_iobuf, buffer, num_bytes, bytes_read);
+	if (*bytes_read == 0) {
+		result = GNOME_VFS_ERROR_EOF;
+	}
+	return result;
 }
 
 static GnomeVFSResult 
Index: modules/ssh-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/ssh-method.c,v
retrieving revision 1.8.2.1
diff -u -r1.8.2.1 ssh-method.c
--- modules/ssh-method.c	19 Jul 2002 07:57:11 -0000	1.8.2.1
+++ modules/ssh-method.c	27 Aug 2002 08:16:50 -0000
@@ -21,7 +21,6 @@
    Author: Ian McKellar <yakk yakk net> */
 
 #include <config.h>
-
 #include <errno.h>
 #include <glib/gstrfuncs.h>
 #include <libgnomevfs/gnome-vfs-cancellation.h>
@@ -153,17 +152,20 @@
 	char ** argv;
 	SshHandle *handle;
 	char *command_line;
+	const gchar *username;
 	int argc;
 	GError *gerror = NULL;
 
-	
+	username = gnome_vfs_uri_get_user_name(uri);
+	if (username == NULL) {
+		username = g_get_user_name();
+	}
 	command_line  = g_strconcat ("ssh -oBatchmode=yes -x -l ", 
-				     gnome_vfs_uri_get_user_name (uri),
+				     username,
 				     " ", gnome_vfs_uri_get_host_name (uri),
-				     " ", command,
+				     " ", "\"LC_ALL=C;", command,"\"",
 				     NULL);
 
-
 	g_shell_parse_argv (command_line, &argc, &argv, &gerror);
 	g_free (command_line);
 	if (gerror) {
@@ -397,8 +399,14 @@
 	 GnomeVFSFileSize *bytes_read,
 	 GnomeVFSContext *context)
 {
-	return ssh_read ((SshHandle *)method_handle, buffer, num_bytes,
-			bytes_read);
+	GnomeVFSResult result;
+
+	result =  ssh_read ((SshHandle *)method_handle, buffer, num_bytes,
+		  	    bytes_read);
+	if (*bytes_read == 0) {	
+		result = GNOME_VFS_ERROR_EOF;
+	}
+	return result;
 }
 
 /* alternative impl:
@@ -436,7 +444,7 @@
 	} else {
 		cmd = g_strdup_printf ("ls -l '/'");
 	}
-
+	
 	result = ssh_connect (&handle, uri, cmd);
 	g_free (name);
 	g_free (cmd);


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