The branch, master has been updated via 989394c6cc4fb5bb9078de567959fb09e348c6a0 (commit) from 52b42f87ea27940300e1c3821d2919ef917d36a7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 989394c6cc4fb5bb9078de567959fb09e348c6a0 Author: Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> Date: Wed Sep 26 10:27:21 2012 +0200 SshMasterConnection emit signal to GUI thread if it need a passphrase to decrypt a ssh key. GUI thread use input dialog to read a passphrase from user ----------------------------------------------------------------------- Summary of changes: debian/changelog | 2 ++ onmainwindow.cpp | 51 +++++++++++++++-------------------- onmainwindow.h | 1 + sshmasterconnection.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++--- sshmasterconnection.h | 7 +++++ 5 files changed, 95 insertions(+), 34 deletions(-) The diff of changes is: diff --git a/debian/changelog b/debian/changelog index 8f9d35a..b681a3f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -57,6 +57,8 @@ x2goclient (3.99.3.0-0~x2go1) UNRELEASED; urgency=low - disable check box "use default sound port" if sound disabled - add support for HTTP proxy - developed by Heinrich Schuchardt (xypron.glpk@gmx.de) - add support for SSH proxy in class SshMasterConnection + - SshMasterConnection emit signal to GUI thread if it need a passphrase to decrypt a ssh key. + GUI thread use input dialog to read a passphrase from user [ Ricardo Diaz ] * New upstream version (3.99.3.0): diff --git a/onmainwindow.cpp b/onmainwindow.cpp index 8bf7a9e..5c2449b 100644 --- a/onmainwindow.cpp +++ b/onmainwindow.cpp @@ -2675,34 +2675,7 @@ void ONMainWindow::slotSelectedFromList ( SessionButton* session ) if ( currentKey.length() >0 ) { - if ( currentKey.indexOf ( "PRIVATE KEY" ) !=-1 ) - { - if ( currentKey.indexOf ( "ENCRYPTED" ) ==-1 ) - nopass=true; - else - nopass=false; - } - else - { - QFile file ( currentKey ); - if ( file.open ( QIODevice::ReadOnly | QIODevice::Text ) ) - { - nopass=true; - while ( !file.atEnd() ) - { - QString line = file.readLine(); - if ( line.indexOf ( "ENCRYPTED" ) !=-1 ) - { - nopass=false; - break; - } - - } - file.close(); - } - else - currentKey=QString::null; - } + nopass=true; } if ( currentKey != QString::null && currentKey != "" && nopass ) { @@ -2780,6 +2753,8 @@ SshMasterConnection* ONMainWindow::startSshConnection ( QString host, QString po connect ( con, SIGNAL ( serverAuthError ( int,QString, SshMasterConnection* ) ),this, SLOT ( slotSshServerAuthError ( int,QString, SshMasterConnection* ) ) ); + connect ( con, SIGNAL ( needPassPhrase(SshMasterConnection*)),this, + SLOT ( slotSshServerAuthPassphrase(SshMasterConnection*)) ); connect ( con, SIGNAL ( userAuthError ( QString ) ),this,SLOT ( slotSshUserAuthError ( QString ) ) ); connect ( con, SIGNAL ( connectionError ( QString,QString ) ), this, SLOT ( slotSshConnectionError ( QString,QString ) ) ); @@ -2864,6 +2839,24 @@ void ONMainWindow::slotServSshConnectionOk(QString server) lproc->startNormal ( "export HOSTNAME && x2golistsessions" ); } +void ONMainWindow::slotSshServerAuthPassphrase(SshMasterConnection* connection) +{ + bool ok; + QString phrase=QInputDialog::getText(0,connection->getUser()+"@"+connection->getHost()+":"+QString::number(connection->getPort()), + tr("Enter passphrase to decrypt a key"),QLineEdit::Password,QString::null, &ok); + if(!ok) + { + phrase=QString::null; + } + else + { + if(phrase==QString::null) + phrase=""; + } + connection->setKeyPhrase(phrase); +} + + void ONMainWindow::slotSshServerAuthError ( int error, QString sshMessage, SshMasterConnection* connection ) { if ( startHidden ) @@ -5136,8 +5129,6 @@ void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus ) } #endif x2goDebug<<"proxy deleted"<<endl; - sshConnection->disconnectSession(); - sshConnection=0; spoolTimer=0l; tunnel=sndTunnel=fsTunnel=0l; soundServer=0l; diff --git a/onmainwindow.h b/onmainwindow.h index 412c00f..6bf9a07 100644 --- a/onmainwindow.h +++ b/onmainwindow.h @@ -880,6 +880,7 @@ private slots: void showSessionStatus(); void slotSshConnectionError ( QString message, QString lastSessionError ); void slotSshServerAuthError ( int error, QString sshMessage, SshMasterConnection* connection ); + void slotSshServerAuthPassphrase ( SshMasterConnection* connection ); void slotSshUserAuthError ( QString error ); void slotSshConnectionOk(); void slotServSshConnectionOk(QString server); diff --git a/sshmasterconnection.cpp b/sshmasterconnection.cpp index fc4d333..0bde770 100644 --- a/sshmasterconnection.cpp +++ b/sshmasterconnection.cpp @@ -52,10 +52,10 @@ #define PROXYTUNNELPORT 44444 #undef DEBUG -//#define DEBUG +// #define DEBUG -//#define SSH_DEBUG #undef SSH_DEBUG +// #define SSH_DEBUG static bool isLibSshInited=false; @@ -233,6 +233,8 @@ void SshMasterConnection::run() connect ( sshProxy, SIGNAL ( serverAuthError ( int,QString,SshMasterConnection* ) ),this, SLOT ( slotSshProxyServerAuthError ( int,QString, SshMasterConnection* ) ) ); + connect ( sshProxy, SIGNAL ( needPassPhrase(SshMasterConnection*)),this, + SIGNAL ( needPassPhrase(SshMasterConnection*)) ); connect ( sshProxy, SIGNAL ( serverAuthAborted()),this, SLOT ( slotSshProxyServerAuthAborted()) ); connect ( sshProxy, SIGNAL ( userAuthError ( QString ) ),this,SLOT ( slotSshProxyUserAuthError ( QString ) ) ); @@ -579,7 +581,32 @@ bool SshMasterConnection::userAuthWithPass() bool SshMasterConnection::userAuthAuto() { - int rc = ssh_userauth_autopubkey ( my_ssh_session, NULL ); + int rc = ssh_userauth_autopubkey ( my_ssh_session, "" ); + int i=0; + while(rc != SSH_AUTH_SUCCESS) + { + keyPhraseReady=false; + emit needPassPhrase(this); + for(;;) + { + bool ready=false; + this->usleep(200); + keyPhraseMutex.lock(); + if(keyPhraseReady) + ready=true; + keyPhraseMutex.unlock(); + if(ready) + break; + } + if(keyPhrase==QString::null) + break; + rc = ssh_userauth_autopubkey ( my_ssh_session, keyPhrase.toAscii() ); + if(i++==2) + { + break; + } + } + if ( rc != SSH_AUTH_SUCCESS ) { QString err=ssh_get_error ( my_ssh_session ); @@ -592,6 +619,15 @@ bool SshMasterConnection::userAuthAuto() return true; } +void SshMasterConnection::setKeyPhrase(QString phrase) +{ + keyPhraseMutex.lock(); + keyPhrase=phrase; + keyPhraseReady=true; + keyPhraseMutex.unlock(); +} + + bool SshMasterConnection::userAuthWithKey() { #ifdef DEBUG @@ -617,7 +653,31 @@ bool SshMasterConnection::userAuthWithKey() #endif } - ssh_private_key prkey=privatekey_from_file(my_ssh_session, keyName.toAscii(), 0, pass.toAscii()); + ssh_private_key prkey=privatekey_from_file(my_ssh_session, keyName.toAscii(), 0,""); + int i=0; + while(!prkey) + { + keyPhraseReady=false; + emit needPassPhrase(this); + for(;;) + { + bool ready=false; + this->usleep(200); + keyPhraseMutex.lock(); + if(keyPhraseReady) + ready=true; + keyPhraseMutex.unlock(); + if(ready) + break; + } + if(keyPhrase==QString::null) + break; + prkey=privatekey_from_file(my_ssh_session, keyName.toAscii(), 0,keyPhrase.toAscii()); + if(i++==2) + { + break; + } + } if (!prkey) { #ifdef DEBUG diff --git a/sshmasterconnection.h b/sshmasterconnection.h index 6a46d28..d9e92cf 100644 --- a/sshmasterconnection.h +++ b/sshmasterconnection.h @@ -75,6 +75,7 @@ public: void addCopyRequest(SshProcess* creator, QString src, QString dst); void disconnectSession(); void writeKnownHosts(bool); + void setKeyPhrase(QString); void setAcceptUnknownServers(bool accept) { acceptUnknownServers=accept; @@ -144,6 +145,10 @@ private: bool writeHostKey; bool writeHostKeyReady; + QString keyPhrase; + bool keyPhraseReady; + QMutex keyPhraseMutex; + QString host; int port; QString user; @@ -192,6 +197,8 @@ signals: void newReverceTunnelConnection(SshProcess* creator, void* newChannel); void reverseListenOk(SshProcess* creator); void connectionOk( QString host); + + void needPassPhrase(SshMasterConnection*); }; hooks/post-receive -- x2goclient.git (X2Go Client) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "x2goclient.git" (X2Go Client).