[vlc-commits] sftp: try the publickey only one time per username

Thomas Guillem git at videolan.org
Tue Oct 31 11:03:25 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 31 10:52:46 2017 +0100| [3c141fd2d80f8f88758d340154426b5e950cc3bd] | committer: Thomas Guillem

sftp: try the publickey only one time per username

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3c141fd2d80f8f88758d340154426b5e950cc3bd
---

 modules/access/sftp.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 6f3721602f..c8670228da 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -309,6 +309,7 @@ static int Open( vlc_object_t* p_this )
     vlc_credential_get( &credential, p_access, "sftp-user", "sftp-pwd",
                         NULL, NULL );
     char* psz_userauthlist = NULL;
+    bool b_publickey_tried = false;
     do
     {
         if (!credential.psz_username || !credential.psz_username[0])
@@ -322,10 +323,15 @@ static int Open( vlc_object_t* p_this )
 
         /* TODO: Follow PreferredAuthentications in ssh_config */
 
-        if( strstr( psz_userauthlist, "publickey" ) != NULL &&
-            ( AuthKeyAgent( p_access, credential.psz_username ) == VLC_SUCCESS ||
-              AuthPublicKey( p_access, psz_home, credential.psz_username ) == VLC_SUCCESS ) )
-            break;
+        if( strstr( psz_userauthlist, "publickey" ) != NULL && !b_publickey_tried )
+        {
+            /* Don't try public key multiple times to avoid getting black
+             * listed */
+            b_publickey_tried = true;
+            if( AuthKeyAgent( p_access, credential.psz_username ) == VLC_SUCCESS
+             || AuthPublicKey( p_access, psz_home, credential.psz_username ) == VLC_SUCCESS )
+                break;
+        }
 
         if( strstr( psz_userauthlist, "password" ) != NULL
          && credential.psz_password != NULL



More information about the vlc-commits mailing list