[X2Go-Commits] [x2goclient] 01/01: SSH Interaction for SSH Broker and SSH Server.
git-admin at x2go.org
git-admin at x2go.org
Fri May 12 11:22:56 CEST 2017
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goclient.
commit 93ab054f170e7108f36d96e9f9768d01657743cd
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date: Fri May 12 11:21:55 2017 +0200
SSH Interaction for SSH Broker and SSH Server.
---
debian/changelog | 1 +
src/InteractionDialog.cpp | 5 +++++
src/InteractionDialog.h | 7 +++++++
src/httpbrokerclient.cpp | 27 ++++++++++++++++++++++++---
src/httpbrokerclient.h | 1 +
src/onmainwindow.cpp | 39 +++++++++++++++++++++++++++++++++++----
src/onmainwindow.h | 4 ++++
src/sshmasterconnection.cpp | 40 +++++++++++++++++++++++++++++++++++++++-
src/sshmasterconnection.h | 4 ++++
9 files changed, 120 insertions(+), 8 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 7991fa1..abc52ab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -159,6 +159,7 @@ x2goclient (4.1.0.1-0x2go1) UNRELEASED; urgency=medium
- Interaction with SSH server (for example for changing
expired password). Fixes: #592.
- Fixing setting widget style issue in InteractionDialog on
+ - SSH Interaction for SSH Broker and SSH Server.
Windows client.
[ Robert Parts ]
* New upstream version (4.1.0.1):
diff --git a/src/InteractionDialog.cpp b/src/InteractionDialog.cpp
index 8f5bb2f..f6a95aa 100644
--- a/src/InteractionDialog.cpp
+++ b/src/InteractionDialog.cpp
@@ -152,3 +152,8 @@ void InteractionDialog::setDisplayMode()
display=true;
}
+void InteractionDialog::setInteractionMode(IMode value)
+{
+ interactionMode=value;
+}
+
diff --git a/src/InteractionDialog.h b/src/InteractionDialog.h
index e2ddf43..76efcfd 100644
--- a/src/InteractionDialog.h
+++ b/src/InteractionDialog.h
@@ -31,6 +31,7 @@ class InteractionDialog: public SVGFrame
Q_OBJECT
public:
+ enum IMode{SESSION,BROKER};
InteractionDialog ( QWidget* parent=0);
virtual ~InteractionDialog();
void reset();
@@ -39,6 +40,11 @@ public:
return interrupted;
}
void setDisplayMode();
+ void setInteractionMode(IMode value);
+ IMode getInteractionMode()
+ {
+ return interactionMode;
+ }
private:
ONMainWindow* mw;
QTextEdit* textEdit;
@@ -46,6 +52,7 @@ private:
QLineEdit* textEntry;
bool interrupted;
bool display;
+ IMode interactionMode;
private slots:
void slotTextEntered();
void slotButtonPressed();
diff --git a/src/httpbrokerclient.cpp b/src/httpbrokerclient.cpp
index 2bde57c..c652d8e 100644
--- a/src/httpbrokerclient.cpp
+++ b/src/httpbrokerclient.cpp
@@ -36,6 +36,7 @@
#include "onmainwindow.h"
#include <QTemporaryFile>
#include <QInputDialog>
+#include "InteractionDialog.h"
HttpBrokerClient::HttpBrokerClient ( ONMainWindow* wnd, ConfigFile* cfg )
@@ -99,6 +100,18 @@ void HttpBrokerClient::createSshConnection()
SLOT ( slotSshConnectionError ( QString,QString ) ) );
connect ( sshConnection, SIGNAL(ioErr(SshProcess*,QString,QString)), this,
SLOT(slotSshIoErr(SshProcess*,QString,QString)));
+
+
+ connect ( sshConnection, SIGNAL(startInteraction(SshMasterConnection*,QString)),mainWindow,
+ SLOT(slotSshInteractionStart(SshMasterConnection*,QString)) );
+ connect ( sshConnection, SIGNAL(updateInteraction(SshMasterConnection*,QString)),mainWindow,
+ SLOT(slotSshInteractionUpdate(SshMasterConnection*,QString)) );
+ connect ( sshConnection, SIGNAL(finishInteraction(SshMasterConnection*)),mainWindow,
+ SLOT(slotSshInteractionFinish(SshMasterConnection*)));
+ connect ( mainWindow->getInteractionDialog(), SIGNAL(textEntered(QString)), sshConnection,
+ SLOT(interactionTextEnter(QString)));
+ connect ( mainWindow->getInteractionDialog(), SIGNAL(interrupt()), sshConnection, SLOT(interactionInterruptSlot()));
+
sshConnection->start();
}
@@ -225,6 +238,12 @@ void HttpBrokerClient::slotSshServerAuthPassphrase(SshMasterConnection* connecti
}
+void HttpBrokerClient::closeSSHInteractionDialog()
+{
+ slotSshUserAuthError("NO_ERROR");
+}
+
+
void HttpBrokerClient::slotSshUserAuthError(QString error)
{
if ( sshConnection )
@@ -234,9 +253,11 @@ void HttpBrokerClient::slotSshUserAuthError(QString error)
sshConnection=0l;
}
- QMessageBox::critical ( 0l,tr ( "Authentication failed." ),error,
- QMessageBox::Ok,
- QMessageBox::NoButton );
+ if(error!="NO_ERROR")
+
+ QMessageBox::critical ( 0l,tr ( "Authentication failed." ),error,
+ QMessageBox::Ok,
+ QMessageBox::NoButton );
emit authFailed();
return;
}
diff --git a/src/httpbrokerclient.h b/src/httpbrokerclient.h
index 107d8ef..f654954 100644
--- a/src/httpbrokerclient.h
+++ b/src/httpbrokerclient.h
@@ -44,6 +44,7 @@ public:
void selectUserSession(const QString& session );
void changePassword(QString newPass);
void testConnection();
+ void closeSSHInteractionDialog();
private:
QNetworkAccessManager* http;
QNetworkRequest* netRequest;
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index d346af3..3c1014e 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -3022,7 +3022,7 @@ void ONMainWindow::slotSshInteractionFinish(SshMasterConnection* connection)
{
if(interDlg->isInterrupted())
{
- slotCloseInteractionDialog();
+ slotCloseInteractionDialog();
}
else
{
@@ -3032,11 +3032,23 @@ void ONMainWindow::slotSshInteractionFinish(SshMasterConnection* connection)
void ONMainWindow::slotCloseInteractionDialog()
{
- slotSshUserAuthError("NO_ERROR");
+ if(interDlg->getInteractionMode()==InteractionDialog::SESSION)
+ {
+ x2goDebug<<"Closed SSH Session interaction";
+ slotSshUserAuthError("NO_ERROR");
+ }
+ else
+ {
+ x2goDebug<<"Closed SSH Broker interaction";
+ if(broker)
+ {
+ interDlg->hide();
+ broker->closeSSHInteractionDialog();
+ }
+ }
}
-
void ONMainWindow::slotSshInteractionStart(SshMasterConnection* connection, QString prompt)
{
sessionStatusDlg->hide();
@@ -3047,11 +3059,30 @@ void ONMainWindow::slotSshInteractionStart(SshMasterConnection* connection, QStr
setEnabled(true);
interDlg->setEnabled(true);
x2goDebug<<"SSH Session prompt:"<<prompt;
-
+ if(connection==sshConnection)
+ {
+ x2goDebug<<"SSH Session interaction";
+ interDlg->setInteractionMode(InteractionDialog::SESSION);
+ }
+ else
+ {
+ interDlg->setInteractionMode(InteractionDialog::BROKER);
+ x2goDebug<<"SSH Broker interaction";
+ }
}
void ONMainWindow::slotSshInteractionUpdate(SshMasterConnection* connection, QString output)
{
+ if(connection==sshConnection)
+ {
+ x2goDebug<<"SSH Session interaction";
+ interDlg->setInteractionMode(InteractionDialog::SESSION);
+ }
+ else
+ {
+ interDlg->setInteractionMode(InteractionDialog::BROKER);
+ x2goDebug<<"SSH Broker interaction";
+ }
interDlg->appendText(output);
x2goDebug<<"SSH Interaction update:"<<output;
}
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index c38e50c..7d9c008 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -342,6 +342,10 @@ public:
void suspendSession ( QString sessId );
bool termSession ( QString sessId,
bool warn=true );
+ const InteractionDialog* getInteractionDialog()
+ {
+ return interDlg;
+ }
void setStatStatus ( QString status=QString::null );
x2goSession getNewSessionFromString ( const QString& string );
void runCommand();
diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp
index e3ef249..2d03044 100644
--- a/src/sshmasterconnection.cpp
+++ b/src/sshmasterconnection.cpp
@@ -461,6 +461,22 @@ int SshMasterConnection::startTunnel(const QString& forwardHost, uint forwardPor
return proc->pid;
}
+void SshMasterConnection::slotSshProxyInteractionFinish(SshMasterConnection* connection)
+{
+ x2goDebug<<"SSH proxy interaction finished";
+ slotSshProxyUserAuthError("NO_ERROR");
+}
+
+void SshMasterConnection::slotSshProxyInteractionStart(SshMasterConnection* connection, QString prompt)
+{
+ emit startInteraction(this, prompt);
+}
+
+void SshMasterConnection::slotSshProxyInteractionUpdate(SshMasterConnection* connection, QString output)
+{
+ emit updateInteraction(this, output);
+}
+
void SshMasterConnection::slotSshProxyConnectionError(QString err1, QString err2)
{
@@ -476,7 +492,10 @@ void SshMasterConnection::slotSshProxyServerAuthError(int errCode, QString err,
void SshMasterConnection::slotSshProxyUserAuthError(QString err)
{
breakLoop=true;
- emit userAuthError(tr("SSH proxy connection error: ")+err);
+ if(err=="NO_ERROR" || err=="NO_PROXY_ERROR")
+ emit userAuthError(err);
+ else
+ emit userAuthError(tr("SSH proxy connection error: ")+err);
}
@@ -524,6 +543,15 @@ void SshMasterConnection::run()
connect ( sshProxy, SIGNAL ( connectionError ( QString,QString ) ), this,
SLOT ( slotSshProxyConnectionError ( QString,QString ) ) );
+ connect ( sshProxy, SIGNAL(startInteraction(SshMasterConnection*,QString)),this,
+ SLOT(slotSshProxyInteractionStart(SshMasterConnection*,QString)) );
+ connect ( sshProxy, SIGNAL(updateInteraction(SshMasterConnection*,QString)),this,
+ SLOT(slotSshProxyInteractionUpdate(SshMasterConnection*,QString)) );
+ connect ( sshProxy, SIGNAL(finishInteraction(SshMasterConnection*)),this,
+ SLOT(slotSshProxyInteractionFinish(SshMasterConnection*)));
+// connect ( interDlg, SIGNAL(textEntered(QString)), con, SLOT(interactionTextEnter(QString)));
+// connect ( interDlg, SIGNAL(interrupt()), con, SLOT(interactionInterruptSlot()));
+
sshProxyReady=false;
sshProxy->start();
@@ -1520,6 +1548,11 @@ bool SshMasterConnection::userAuthKrb()
void SshMasterConnection::interactionTextEnter(QString text)
{
+ if(sshProxy && ! sshProxyReady)
+ {
+ sshProxy->interactionTextEnter(text);
+ return;
+ }
interactionInputMutex.lock();
interactionInputText=text;
interactionInputMutex.unlock();
@@ -1527,6 +1560,11 @@ void SshMasterConnection::interactionTextEnter(QString text)
void SshMasterConnection::interactionInterruptSlot()
{
+ if(sshProxy && ! sshProxyReady)
+ {
+ sshProxy->interactionInterruptSlot();
+ return;
+ }
interactionInputMutex.lock();
interactionInterrupt=true;
interactionInputMutex.unlock();
diff --git a/src/sshmasterconnection.h b/src/sshmasterconnection.h
index f95f653..96c2165 100644
--- a/src/sshmasterconnection.h
+++ b/src/sshmasterconnection.h
@@ -148,6 +148,10 @@ private slots:
void slotSshProxyTunnelOk(int);
void slotSshProxyTunnelFailed(bool result, QString output,
int);
+ void slotSshProxyInteractionStart ( SshMasterConnection* connection, QString prompt );
+ void slotSshProxyInteractionUpdate ( SshMasterConnection* connection, QString output );
+ void slotSshProxyInteractionFinish ( SshMasterConnection* connection);
+
public slots:
void interactionTextEnter(QString text);
void interactionInterruptSlot();
--
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