[gvfs] ftp: Fix stupid proxy servers disconnecting on FEAT



commit ad4b1f753866731e6354e367a12b66b9867d5827
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jun 14 03:47:58 2011 +0200

    ftp: Fix stupid proxy servers disconnecting on FEAT
    
    A bunch of proxy servers assume that the first command sent by an FTP
    server is USER and if it isn't, they bomb out. We do want to support
    FEAT-before-USER though so we can do secure FTP (if we ever actually
    implement it). So we need to make sure we try it at least once and if it
    fails, we open a new connection and try with USER instead.

 daemon/gvfsbackendftp.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 8cca980..d24b259 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -417,6 +417,7 @@ do_mount (GVfsBackend *backend,
   GNetworkAddress *addr;
   guint port;
 
+restart:
   task.conn = g_vfs_ftp_connection_new (ftp->addr, task.cancellable, &task.error);
   /* fail fast here. No need to ask for a password if we know the hostname
    * doesn't exist or the given host/port doesn't have an ftp server running.
@@ -429,11 +430,17 @@ do_mount (GVfsBackend *backend,
 
   /* send pre-login commands */
   g_vfs_ftp_task_receive (&task, 0, NULL);
-  if (!gvfs_backend_ftp_determine_features (&task))
+  if (!g_vfs_backend_ftp_uses_workaround (ftp, G_VFS_FTP_WORKAROUND_FEAT_AFTER_LOGIN) &&
+      !gvfs_backend_ftp_determine_features (&task))
     {
-      g_vfs_ftp_task_clear_error (&task);
       g_vfs_backend_ftp_use_workaround (ftp, G_VFS_FTP_WORKAROUND_FEAT_AFTER_LOGIN);
       ftp->features = 0;
+      g_vfs_ftp_task_clear_error (&task);
+      if (!g_vfs_ftp_connection_is_usable (task.conn))
+        {
+          g_vfs_ftp_connection_free (task.conn);
+          goto restart;
+        }
     }
 
   addr = G_NETWORK_ADDRESS (ftp->addr);



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