[gvfs/sftp-multiplexing-2fa: 1/2] sftp: Use connection multiplexing instead of multiple connections




commit 34eb6f637203da43128e19c541b96a4f4c5e2e60
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Sep 30 15:01:04 2020 +0200

    sftp: Use connection multiplexing instead of multiple connections
    
    Currently, two connections are established in order to be responsive
    even during file transfers. However, this causes duplicated prompts
    when ssh-askpass is used. Let's use connection multiplexing instead
    to avoid those duplicated prompts.
    
    Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/510

 daemon/gvfsbackendsftp.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index 1bb4a673..1ecdd0d8 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -465,7 +465,7 @@ setup_ssh_environment (void)
 }
 
 static char **
-setup_ssh_commandline (GVfsBackend *backend)
+setup_ssh_commandline (GVfsBackend *backend, const gchar *control_path)
 {
   GVfsBackendSftp *op_backend = G_VFS_BACKEND_SFTP (backend);
   guint last_arg;
@@ -488,7 +488,8 @@ setup_ssh_commandline (GVfsBackend *backend)
 #ifndef USE_PTY
       args[last_arg++] = g_strdup ("-oBatchMode yes");
 #endif
-    
+      args[last_arg++] = g_strdup ("-oControlMaster auto");
+      args[last_arg++] = g_strdup_printf ("-oControlPath=%s/%%C", control_path);
     }
   else if (op_backend->client_vendor == SFTP_VENDOR_SSH)
     args[last_arg++] = g_strdup ("-x");
@@ -1841,8 +1842,13 @@ setup_connection (GVfsBackend *backend,
   gboolean res;
   char *extension_name, *extension_data;
   int i;
+  gchar *control_path = NULL;
+
+  control_path = g_build_filename (g_get_user_runtime_dir (), "gvfsd-sftp", NULL);
+  g_mkdir (control_path, 0700);
 
-  args = setup_ssh_commandline (backend);
+  args = setup_ssh_commandline (backend, control_path);
+  g_free (control_path);
 
   if (!spawn_ssh (backend,
                  args, &pid,


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