[gvfs/wip/oholy/sftp-new-openssh-prompts] sftp: Adapt on new OpenSSH password prompts




commit fde319a21e9fdd02e8c1be20db6d7271e8889625
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Oct 8 10:35:10 2021 +0200

    sftp: Adapt on new OpenSSH password prompts
    
    SFTP backend fails when connecting with the "Timed out when logging in"
    error with the recent OpenSSH versions. This is because their password
    prompts are now prefixed by the `(user@host)` string, which breaks our
    `g_str_has_prefix` checks. Let's use `strstr` instead to fix this issue
    and also to not break compatibility with old versions and other vendors.
    
    Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/584

 daemon/gvfsbackendsftp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index 61c20a39..7649b882 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -1106,10 +1106,10 @@ handle_login (GVfsBackend *backend,
       if (g_str_has_suffix (buffer, "password: ") ||
           g_str_has_suffix (buffer, "Password: ") ||
           g_str_has_suffix (buffer, "Password:")  ||
-          g_str_has_prefix (buffer, "Password for ") ||
-          g_str_has_prefix (buffer, "Enter Kerberos password") ||
-          g_str_has_prefix (buffer, "Enter passphrase for key") ||
-          g_str_has_prefix (buffer, "Enter PASSCODE"))
+          strstr (buffer, "Password for ") ||
+          strstr (buffer, "Enter Kerberos password") ||
+          strstr (buffer, "Enter passphrase for key") ||
+          strstr (buffer, "Enter PASSCODE"))
         {
           gboolean aborted = FALSE;
           gsize bytes_written;
@@ -1265,8 +1265,8 @@ handle_login (GVfsBackend *backend,
               break;
             }
         }
-      else if (g_str_has_prefix (buffer, "Verification code") ||
-               g_str_has_prefix (buffer, "One-time password"))
+      else if (strstr (buffer, "Verification code") ||
+               strstr (buffer, "One-time password"))
         {
           gchar *verification_code = NULL;
           gboolean aborted = FALSE;


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