[gvfs] sftp: Improve error messages on connection setup



commit 0da49dd9d18f8f930a20f89fdf46388dca21a0fa
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Sun Jul 19 08:50:22 2015 +0100

    sftp: Improve error messages on connection setup
    
    Log all the messages from SSH's stderr.
    
    If the remote server does not have sftp setup correctly, it fails with
    "subsystem request failed". Report this as "Connection refused".
    
    If the error is unknown, report it as "Connection failed" rather than
    "SSH program unexpectedly exited" which shouldn't be exposed to users.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752403

 daemon/gvfsbackendsftp.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index c975806..1411cea 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -339,10 +339,11 @@ look_for_stderr_errors (Connection *conn, GError **error)
           /* Error (real or WOULDBLOCK) or EOF */
           g_set_error_literal (error,
                               G_IO_ERROR, G_IO_ERROR_FAILED,
-                              _("SSH program unexpectedly exited"));
+                               _("Connection failed"));
           return;
         }
-      
+
+      DEBUG ("stderr: %s\n", line);
       if (strstr (line, "Permission denied") != NULL)
         {
           g_set_error_literal (error,
@@ -364,7 +365,8 @@ look_for_stderr_errors (Connection *conn, GError **error)
                               _("No route to host"));
           return;
         }
-      else if (strstr (line, "Connection refused") != NULL)
+      else if (strstr (line, "Connection refused") != NULL ||
+               strstr (line, "subsystem request failed") != NULL)
         {
           g_set_error_literal (error,
                               G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
@@ -704,7 +706,7 @@ read_reply_sync (Connection *conn, gsize *len_out, GError **error)
     {
       g_set_error_literal (error,
                           G_IO_ERROR, G_IO_ERROR_FAILED,
-                          _("SSH program unexpectedly exited"));
+                           _("Connection failed"));
       return NULL;
     }
   


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