This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient.
commit d8c10770678414652fe024fdc8a953b0649033d3 Author: Mihai Moldovan <io...@ionic.de> Date: Fri Nov 10 21:23:45 2017 +0100 src/{httpbrokerclient,onmainwindow,sshmasterconnection}.{cpp,h}: introduce new passphrase_type enum and replace the old verificationCode boolean value with that. Allows using more messages, including a new one for plain password prompts. Adapt usage accordingly. The implementation is ugly, but there's no good way around that (short of using C++11 features). The enum would really logically belong to ONMainWindow, but 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. --- debian/changelog | 9 +++++++ src/httpbrokerclient.cpp | 54 ++++++++++++++++++++------------------- src/httpbrokerclient.h | 2 +- src/onmainwindow.cpp | 61 +++++++++++++++++++++++++-------------------- src/onmainwindow.h | 2 +- src/sshmasterconnection.cpp | 10 ++++---- src/sshmasterconnection.h | 10 +++++++- 7 files changed, 88 insertions(+), 60 deletions(-) diff --git a/debian/changelog b/debian/changelog index 91f6478..13568ba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,15 @@ x2goclient (4.1.1.1-0x2go1) UNRELEASED; urgency=medium in MacPorts. - src/sshmasterconnection.cpp: don't ask for private key passphrase if auto-login merely failed due to the server denying the public key. + - src/{httpbrokerclient,onmainwindow,sshmasterconnection}.{cpp,h}: + introduce new passphrase_type enum and replace the old verificationCode + boolean value with that. Allows using more messages, including a new one + for plain password prompts. Adapt usage accordingly. The implementation + is ugly, but there's no good way around that (short of using C++11 + features). The enum would really logically belong to ONMainWindow, but + 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. [ Oleksandr Shneyder ] * Change echo mode for user input in InteractionDialog. diff --git a/src/httpbrokerclient.cpp b/src/httpbrokerclient.cpp index 7cc1403..1540e98 100644 --- a/src/httpbrokerclient.cpp +++ b/src/httpbrokerclient.cpp @@ -93,8 +93,8 @@ void HttpBrokerClient::createSshConnection() connect ( sshConnection, SIGNAL ( connectionOk(QString)), this, SLOT ( slotSshConnectionOk() ) ); connect ( sshConnection, SIGNAL ( serverAuthError ( int,QString, SshMasterConnection* ) ),this, SLOT ( slotSshServerAuthError ( int,QString, SshMasterConnection* ) ) ); - connect ( sshConnection, SIGNAL ( needPassPhrase(SshMasterConnection*, bool)),this, - SLOT ( slotSshServerAuthPassphrase(SshMasterConnection*, bool)) ); + connect ( sshConnection, SIGNAL ( needPassPhrase(SshMasterConnection*, SshMasterConnection::passphrase_types)),this, + SLOT ( slotSshServerAuthPassphrase(SshMasterConnection*, SshMasterConnection::passphrase_types)) ); connect ( sshConnection, SIGNAL ( userAuthError ( QString ) ),this,SLOT ( slotSshUserAuthError ( QString ) ) ); connect ( sshConnection, SIGNAL ( connectionError(QString,QString)), this, SLOT ( slotSshConnectionError ( QString,QString ) ) ); @@ -209,34 +209,38 @@ void HttpBrokerClient::slotSshServerAuthError(int error, QString sshMessage, Ssh } -void HttpBrokerClient::slotSshServerAuthPassphrase(SshMasterConnection* connection, bool verificationCode) +void HttpBrokerClient::slotSshServerAuthPassphrase(SshMasterConnection* connection, SshMasterConnection::passphrase_types passphrase_type) { bool ok; QString message; - if(verificationCode) - { - message=tr("Verification code:"); - } - else - { - message=tr("Enter passphrase to decrypt a key"); - } - - - QString phrase=QInputDialog::getText(0,connection->getUser()+"@"+connection->getHost()+":"+QString::number(connection->getPort()), - message, QLineEdit::Password,QString::null, &ok); - if(!ok) - { - phrase=QString::null; - } - else - { - if(phrase==QString::null) - phrase=""; + switch (passphrase_type) { + case SshMasterConnection::PASSPHRASE_PRIVKEY: + message = tr ("Enter passphrase to decrypt a key"); + ok = true; + break; + case SshMasterConnection::PASSPHRASE_CHALLENGE: + message = tr ("Verification code:"); + ok = true; + break; + case SshMasterConnection::PASSPHRASE_PASSWORD: + message = tr ("Enter user account password:"); + ok = true; + break; + default: + x2goDebug << "Unknown passphrase type requested! Was: " << passphrase_type << endl; + ok = false; + break; + } + + if (ok) { + QString phrase = QInputDialog::getText (0, connection->getUser () + "@" + connection->getHost () + ":" + QString::number (connection->getPort ()), + message, QLineEdit::Password, QString (""), &ok); + if (!ok) { + phrase = QString (""); + } + connection->setKeyPhrase (phrase); } - connection->setKeyPhrase(phrase); - } void HttpBrokerClient::closeSSHInteractionDialog() diff --git a/src/httpbrokerclient.h b/src/httpbrokerclient.h index f654954..1b62b26 100644 --- a/src/httpbrokerclient.h +++ b/src/httpbrokerclient.h @@ -72,7 +72,7 @@ private slots: QString getHexVal ( const QByteArray& ba ); void slotSshConnectionError ( QString message, QString lastSessionError ); void slotSshServerAuthError ( int error, QString sshMessage, SshMasterConnection* connection ); - void slotSshServerAuthPassphrase ( SshMasterConnection* connection, bool verificationCode=false ); + void slotSshServerAuthPassphrase ( SshMasterConnection* connection, SshMasterConnection::passphrase_types passphrase_type = SshMasterConnection::PASSPHRASE_PRIVKEY ); void slotSshUserAuthError ( QString error ); void slotSshConnectionOk(); void slotListSessions ( bool success, QString answer, int pid); diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index b4b8f28..cd6cab5 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -2989,8 +2989,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*, bool)),this, - SLOT ( slotSshServerAuthPassphrase(SshMasterConnection*, bool)) ); + connect ( con, SIGNAL ( needPassPhrase(SshMasterConnection*, SshMasterConnection::passphrase_types)),this, + SLOT ( slotSshServerAuthPassphrase(SshMasterConnection*, SshMasterConnection::passphrase_types)) ); connect ( con, SIGNAL ( needChallengeResponse(SshMasterConnection*, QString)),this, SLOT ( slotSshServerAuthChallengeResponse(SshMasterConnection*, QString)) ); connect ( con, SIGNAL ( userAuthError ( QString ) ),this,SLOT ( slotSshUserAuthError ( QString ) ) ); @@ -3160,34 +3160,41 @@ void ONMainWindow::slotSshInteractionUpdate(SshMasterConnection* connection, QSt x2goDebug<<"SSH Interaction update:"<<output; } -void ONMainWindow::slotSshServerAuthPassphrase(SshMasterConnection* connection, bool verificationCode) +void ONMainWindow::slotSshServerAuthPassphrase(SshMasterConnection* connection, SshMasterConnection::passphrase_types passphrase_type) { bool ok; QString message; - if(verificationCode) - { - message=tr("Verification code:"); - } - else - { - message=tr("Enter passphrase to decrypt a key"); - } - QString phrase=QInputDialog::getText(0,connection->getUser()+"@"+connection->getHost()+":"+QString::number(connection->getPort()), - message,QLineEdit::Password,QString::null, &ok); - if(!ok) - { - phrase=QString::null; - } - else - { - if(phrase==QString::null) - phrase=""; - } - connection->setKeyPhrase(phrase); - if(isHidden()) - { - show(); - QTimer::singleShot(1, this, SLOT(hide())); + + switch (passphrase_type) { + case SshMasterConnection::PASSPHRASE_PRIVKEY: + message = tr ("Enter passphrase to decrypt a key"); + ok = true; + break; + case SshMasterConnection::PASSPHRASE_CHALLENGE: + message = tr ("Verification code:"); + ok = true; + break; + case SshMasterConnection::PASSPHRASE_PASSWORD: + message = tr ("Enter user account password:"); + ok = true; + break; + default: + x2goDebug << "Unknown passphrase type requested! Was: " << passphrase_type << endl; + ok = false; + break; + } + + if (ok) { + QString phrase = QInputDialog::getText (0, connection->getUser () + "@" + connection->getHost () + ":" + QString::number (connection->getPort ()), + message, QLineEdit::Password, QString (""), &ok); + if (!ok) { + phrase = QString (""); + } + connection->setKeyPhrase (phrase); + if(isHidden ()) { + show (); + QTimer::singleShot (1, this, SLOT (hide ())); + } } } diff --git a/src/onmainwindow.h b/src/onmainwindow.h index 5d3d728..0a115bb 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -1045,7 +1045,7 @@ private slots: void showSessionStatus(); void slotSshConnectionError ( QString message, QString lastSessionError ); void slotSshServerAuthError ( int error, QString sshMessage, SshMasterConnection* connection ); - void slotSshServerAuthPassphrase ( SshMasterConnection* connection, bool verificationCode ); + void slotSshServerAuthPassphrase ( SshMasterConnection* connection, SshMasterConnection::passphrase_types passphrase_type ); void slotSshInteractionStart ( SshMasterConnection* connection, QString prompt ); void slotSshInteractionUpdate ( SshMasterConnection* connection, QString output ); void slotSshInteractionFinish ( SshMasterConnection* connection); diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 6ccf099..7831265 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -528,8 +528,8 @@ void SshMasterConnection::run() connect ( sshProxy, SIGNAL ( serverAuthError ( int,QString,SshMasterConnection* ) ),this, SLOT ( slotSshProxyServerAuthError ( int,QString, SshMasterConnection* ) ) ); - connect ( sshProxy, SIGNAL ( needPassPhrase(SshMasterConnection*, bool)),this, - SIGNAL ( needPassPhrase(SshMasterConnection*, bool)) ); + connect ( sshProxy, SIGNAL ( needPassPhrase(SshMasterConnection*, SshMasterConnection::passphrase_types)),this, + SIGNAL ( needPassPhrase(SshMasterConnection*, SshMasterConnection::passphrase_types)) ); connect ( sshProxy, SIGNAL ( serverAuthAborted()),this, SLOT ( slotSshProxyServerAuthAborted()) ); connect ( sshProxy, SIGNAL ( userAuthError ( QString ) ),this,SLOT ( slotSshProxyUserAuthError ( QString ) ) ); @@ -1180,7 +1180,7 @@ bool SshMasterConnection::userChallengeAuth() if (need_to_display_auth_code_prompt) { emit needChallengeResponse(this, pr); } else { - emit needPassPhrase(this, true); + emit needPassPhrase(this, PASSPHRASE_CHALLENGE); } for(;;) { @@ -1303,7 +1303,7 @@ bool SshMasterConnection::userAuthAuto() /* This section should only be executed if rc is SSH_AUTH_ERROR. */ keyPhraseReady=false; - emit needPassPhrase(this, false); + emit needPassPhrase(this, PASSPHRASE_PRIVKEY); for(;;) { bool ready=false; @@ -1413,7 +1413,7 @@ bool SshMasterConnection::userAuthWithKey() #endif { keyPhraseReady=false; - emit needPassPhrase(this, false); + emit needPassPhrase(this, PASSPHRASE_PRIVKEY); for(;;) { bool ready=false; diff --git a/src/sshmasterconnection.h b/src/sshmasterconnection.h index e6924e0..6f4a442 100644 --- a/src/sshmasterconnection.h +++ b/src/sshmasterconnection.h @@ -74,6 +74,14 @@ class SshMasterConnection: public QThread PROPERTY(bool, kerberosDelegation) public: enum ProxyType {PROXYSSH, PROXYHTTP}; + + enum passphrase_types { + PASSPHRASE_PRIVKEY, + PASSPHRASE_CHALLENGE, + PASSPHRASE_PASSWORD, + PASSPHRASE_UNKNOWN + }; + void run(); SshMasterConnection(QObject* parent, QString host, int port, bool acceptUnknownServers, QString user, QString pass, QString key, bool autologin, bool krblogin=false, @@ -228,7 +236,7 @@ signals: void connectionOk( QString host); - void needPassPhrase(SshMasterConnection*, bool verificationCode); + void needPassPhrase(SshMasterConnection*, passphrase_types); void needChallengeResponse(SshMasterConnection*, QString Challenge); void startInteraction(SshMasterConnection*, QString prompt); void finishInteraction(SshMasterConnection*); -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git _______________________________________________ x2go-commits mailing list x2go-commits@lists.x2go.org https://lists.x2go.org/listinfo/x2go-commits