[X2Go-Commits] [x2goclient] 03/06: src/sshmasterconnection.cpp: query for password if it wasn't already provided.

git-admin at x2go.org git-admin at x2go.org
Fri Nov 10 23:09:18 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit d0be65ee5177c2df4761c1fba18e2967b49951aa
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Fri Nov 10 21:33:46 2017 +0100

    src/sshmasterconnection.cpp: query for password if it wasn't already provided.
    
    This usually happens if auto-login is enabled, which bypasses the
    password prompt. If auto-login fails, authentication normally continues
    via challenge auth or plain passwords, but since users had no chance to
    input a password, such authentication will always fail.
    
    Give users a way to enter passwords, in case the auto-login failed.
---
 debian/changelog            |  6 +++++
 src/sshmasterconnection.cpp | 55 ++++++++++++++++++++++++++++-----------------
 2 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 13568ba..5a04c84 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,12 @@ x2goclient (4.1.1.1-0x2go1) UNRELEASED; urgency=medium
       since we also have to use it in SshMasterConnection, that may not
       include onmainwindow.h to avoid a circular dependency, it has to be
       part of SshMasterConnection for now.
+    - src/sshmasterconnection.cpp: query for password if it wasn't already
+      provided. This usually happens if auto-login is enabled, which bypasses
+      the password prompt. If auto-login fails, authentication normally
+      continues via challenge auth or plain passwords, but since users had no
+      chance to input a password, such authentication will always fail. Give
+      users a way to enter passwords, in case the auto-login failed.
 
   [ Oleksandr Shneyder ]
   * Change echo mode for user input in InteractionDialog.
diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp
index 7831265..fb0dee8 100644
--- a/src/sshmasterconnection.cpp
+++ b/src/sshmasterconnection.cpp
@@ -1250,36 +1250,51 @@ bool SshMasterConnection::userAuthWithPass()
 
     int method = ssh_userauth_list(my_ssh_session, NULL);
 
-    if (method& SSH_AUTH_METHOD_INTERACTIVE)
-    {
-#ifdef DEBUG
-        x2goDebug<<"Challenge authentication requested."<<endl;
-#endif
-        challengeAuthPasswordAccepted=false;
-        ret = userChallengeAuth();
+    if (method & SSH_AUTH_METHOD_INTERACTIVE) {
+        x2goDebug << "Challenge authentication requested." << endl;
+
+        challengeAuthPasswordAccepted = false;
+        ret = userChallengeAuth ();
+
+        if (!ret) {
+            x2goDebug << "Challenge authentication failed." << endl;
+        }
     }
 
     if (!ret) {
-        x2goDebug << "Challenge authentication failed. Trying password mechanism if available." << endl;
+        x2goDebug << "Trying password mechanism if available." << endl;
     }
 
-    if ((!ret) && (method & SSH_AUTH_METHOD_PASSWORD))
-    {
-        if (!ret) {
-            x2goDebug << "Password mechanism available. Continuing." << endl;
-        }
+    if ((!ret) && (method & SSH_AUTH_METHOD_PASSWORD)) {
+        x2goDebug << "Password mechanism available. Continuing." << endl;
 
-#ifdef DEBUG
-        x2goDebug<<"Password authentication requested."<<endl;
-#endif
-        int rc = ssh_userauth_password ( my_ssh_session, NULL, pass.toLatin1() );
+        QString auth_password = pass;
+
+        if (auth_password.isEmpty ()) {
+            keyPhraseReady = false;
+            emit needPassPhrase (this, PASSPHRASE_PASSWORD);
+
+            for (bool ready = false; !ready;) {
+                this->usleep (200);
+
+                keyPhraseMutex.lock ();
+                ready = keyPhraseReady;
+                keyPhraseMutex.unlock ();
+            }
+
+            if (keyPhrase.isNull ()) {
+                return (ret);
+            }
+            else {
+                auth_password = keyPhrase;
+            }
+        }
+        int rc = ssh_userauth_password (my_ssh_session, NULL, auth_password.toLatin1 ());
         if ( rc != SSH_AUTH_SUCCESS )
         {
             QString err=ssh_get_error ( my_ssh_session );
             authErrors<<err;
-#ifdef DEBUG
-            x2goDebug<<"userAuthWithPass failed:" <<err<<endl;
-#endif
+            x2goDebug << "Password authentication failed: " << err << endl;
         }
         else {
             ret = true;

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list