The branch, master has been updated
via ef8c9486314e87bf6aeb748b46b1c35f1b975213 (commit)
from f2b6a54b89c6b8811bb85bedd376ac74621bc97b (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 ef8c9486314e87bf6aeb748b46b1c35f1b975213
Author: Oleksandr Shneyder <oleksandr.shneyder(a)obviously-nice.de>
Date: Mon Oct 1 16:07:15 2012 +0200
SshProcess is only usable over SshMasterConnection
-----------------------------------------------------------------------
Summary of changes:
debian/changelog | 1 +
httpbrokerclient.cpp | 42 ++---
httpbrokerclient.h | 8 +-
onmainwindow.cpp | 388 +++++++++++++++--------------------------------
onmainwindow.h | 43 +++---
onmainwindow_privat.h | 1 -
sshmasterconnection.cpp | 122 +++++++++++----
sshmasterconnection.h | 14 +-
sshprocess.cpp | 33 ++--
sshprocess.h | 20 +--
10 files changed, 286 insertions(+), 386 deletions(-)
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 42f5655..74a4339 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -73,6 +73,7 @@ x2goclient (3.99.3.0-0~x2go1) UNRELEASED; urgency=low
instead.
- reduce listen interval for ssh-tunnell to 100 msec
- fixed visibility of SSH-proxy box with direct RDP sessions
+ - SshProcess is only usable over SshMasterConnection
[ Ricardo Diaz ]
* New upstream version (3.99.3.0):
diff --git a/httpbrokerclient.cpp b/httpbrokerclient.cpp
index f84f95e..ca4bbec 100644
--- a/httpbrokerclient.cpp
+++ b/httpbrokerclient.cpp
@@ -26,7 +26,6 @@
#include "onmainwindow.h"
#include <QTemporaryFile>
#include <QInputDialog>
-#include <sshprocess.h>
HttpBrokerClient::HttpBrokerClient ( ONMainWindow* wnd, ConfigFile* cfg )
{
@@ -236,11 +235,8 @@ void HttpBrokerClient::getUserSessions()
createSshConnection();
return;
}
- SshProcess* proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotListSessions ( bool, QString,
- SshProcess* ) ) );
- proc->startNormal ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task listsessions" );
+ sshConnection->executeCommand ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task listsessions",
+ this, SLOT ( slotListSessions ( bool, QString,int ) ));
}
}
@@ -262,10 +258,8 @@ void HttpBrokerClient::selectUserSession(const QString& session)
}
else
{
- SshProcess* proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotSelectSession(bool,QString,SshProcess*)));
- proc->startNormal ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task selectsession --sid "+session );
+ sshConnection->executeCommand ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task selectsession --sid "+session,
+ this,SLOT ( slotSelectSession(bool,QString,int)));
}
}
@@ -289,10 +283,8 @@ void HttpBrokerClient::changePassword(QString newPass)
}
else
{
- SshProcess* proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotPassChanged(bool,QString,SshProcess*)));
- proc->startNormal ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task setpass --newpass "+newPass );
+ sshConnection->executeCommand ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task setpass --newpass "+newPass, this,
+ SLOT ( slotPassChanged(bool,QString,int)));
}
}
@@ -311,10 +303,8 @@ void HttpBrokerClient::testConnection()
}
else
{
- SshProcess* proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotSelectSession(bool,QString,SshProcess*)));
- proc->startNormal ( config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task testcon" );
+ sshConnection->executeCommand(config->sshBrokerBin+" --authid "+config->brokerUserId+ " --task testcon",
+ this, SLOT ( slotSelectSession(bool,QString,int)));
}
}
@@ -350,10 +340,8 @@ bool HttpBrokerClient::checkAccess(QString answer )
}
-void HttpBrokerClient::slotConnectionTest(bool success, QString answer, SshProcess* proc)
+void HttpBrokerClient::slotConnectionTest(bool success, QString answer, int)
{
- if(proc)
- delete proc;
if(!success)
{
x2goDebug<<answer;
@@ -372,10 +360,8 @@ void HttpBrokerClient::slotConnectionTest(bool success, QString answer, SshProce
}
-void HttpBrokerClient::slotListSessions(bool success, QString answer, SshProcess* proc)
+void HttpBrokerClient::slotListSessions(bool success, QString answer, int)
{
- if(proc)
- delete proc;
if(!success)
{
x2goDebug<<answer;
@@ -389,10 +375,8 @@ void HttpBrokerClient::slotListSessions(bool success, QString answer, SshProcess
emit sessionsLoaded();
}
-void HttpBrokerClient::slotPassChanged(bool success, QString answer, SshProcess* proc)
+void HttpBrokerClient::slotPassChanged(bool success, QString answer, int)
{
- if(proc)
- delete proc;
if(!success)
{
x2goDebug<<answer;
@@ -405,10 +389,8 @@ void HttpBrokerClient::slotPassChanged(bool success, QString answer, SshProcess*
}
-void HttpBrokerClient::slotSelectSession(bool success, QString answer, SshProcess* proc)
+void HttpBrokerClient::slotSelectSession(bool success, QString answer, int)
{
- if(proc)
- delete proc;
if(!success)
{
x2goDebug<<answer;
diff --git a/httpbrokerclient.h b/httpbrokerclient.h
index 02f5d3d..bb7e9cd 100644
--- a/httpbrokerclient.h
+++ b/httpbrokerclient.h
@@ -62,10 +62,10 @@ private slots:
void slotSshServerAuthPassphrase ( SshMasterConnection* connection );
void slotSshUserAuthError ( QString error );
void slotSshConnectionOk();
- void slotListSessions ( bool success, QString answer, SshProcess* proc);
- void slotSelectSession ( bool success, QString answer, SshProcess* proc);
- void slotPassChanged ( bool success, QString answer, SshProcess* proc);
- void slotConnectionTest( bool success, QString answer, SshProcess* proc);
+ void slotListSessions ( bool success, QString answer, int pid);
+ void slotSelectSession ( bool success, QString answer, int pid);
+ void slotPassChanged ( bool success, QString answer, int pid);
+ void slotConnectionTest( bool success, QString answer, int pid);
public slots:
void getUserSessions();
diff --git a/onmainwindow.cpp b/onmainwindow.cpp
index 89e2964..8f452cb 100644
--- a/onmainwindow.cpp
+++ b/onmainwindow.cpp
@@ -1267,9 +1267,8 @@ void ONMainWindow::closeClient()
}
if ( sshConnection && !useLdap)
{
- sshConnection->disconnectSession();
x2goDebug<<"waiting sshConnection to finish\n";
- sshConnection->wait ( 10000 );
+ delete sshConnection;
x2goDebug<<"sshConnection is closed\n";
sshConnection=0;
}
@@ -1279,9 +1278,8 @@ void ONMainWindow::closeClient()
{
if (serverSshConnections[i])
{
- serverSshConnections[i]->disconnectSession();
x2goDebug<<"waiting sshConnection to finish\n";
- serverSshConnections[i]->wait ( 10000 );
+ delete serverSshConnections[i];
x2goDebug<<"sshConnection is closed\n";
}
}
@@ -1768,7 +1766,7 @@ void ONMainWindow::slotPassEnter()
QString host=firstServer;
passwd=getCurrentPass();
if (sshConnection)
- sshConnection->disconnectSession();
+ delete sshConnection;
sshConnection=startSshConnection ( host,sshPort,acceptRsa,user,passwd,true, false );
#endif
@@ -2850,15 +2848,8 @@ void ONMainWindow::slotServSshConnectionOk(QString server)
SshMasterConnection* con=findServerSshConnection(server);
if (!con)
return;
- SshProcess* lproc;
- lproc=new SshProcess ( con, this );
- connect ( lproc,SIGNAL ( sshFinished ( bool,
- QString,SshProcess* ) ),
- this,SLOT (
- slotListAllSessions ( bool,
- QString,SshProcess* ) ) );
x2goDebug<<"getting sessions on "<<server<<endl;
- lproc->startNormal ( "export HOSTNAME && x2golistsessions" );
+ con->executeCommand( "export HOSTNAME && x2golistsessions", this, SLOT (slotListAllSessions ( bool,QString,int ) ));
}
void ONMainWindow::slotSshServerAuthPassphrase(SshMasterConnection* connection)
@@ -3042,25 +3033,16 @@ void ONMainWindow::continueNormalSession()
slotListSessions(true,QString::null,0);
return;
}
- SshProcess* proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotListSessions ( bool, QString,
- SshProcess* ) ) );
if ( !shadowSession )
- proc->startNormal ( "export HOSTNAME && x2golistsessions" );
+ sshConnection->executeCommand ( "export HOSTNAME && x2golistsessions", this,SLOT ( slotListSessions ( bool, QString,int )));
else
- proc->startNormal ( "export HOSTNAME && x2golistdesktops" );
+ sshConnection->executeCommand ( "export HOSTNAME && x2golistdesktops", this,SLOT ( slotListSessions ( bool, QString,int )));
}
void ONMainWindow::continueLDAPSession()
{
-
-
- SshProcess* proc=new SshProcess ( sshConnection,this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotGetServers ( bool, QString,SshProcess* ) ) );
- proc->startNormal ( "x2gogetservers" );
+ sshConnection->executeCommand ( "x2gogetservers", this, SLOT ( slotGetServers ( bool, QString,int ) ));
}
#ifdef Q_OS_LINUX
@@ -3243,8 +3225,10 @@ bool ONMainWindow::startSession ( const QString& sid )
krblogin=st->setting()->value ( sid+"/krblogin",
( QVariant ) false ).toBool();
#ifdef Q_OS_LINUX
- directRDP=st->setting()->value ( sid+"/directrdp",
- ( QVariant ) false ).toBool();
+ directRDP=(st->setting()->value ( sid+"/directrdp",
+ ( QVariant ) false ).toBool() && cmd == "RDP");
+
+
if (cmd =="RDP" && directRDP)
{
startDirectRDP();
@@ -3260,7 +3244,7 @@ bool ONMainWindow::startSession ( const QString& sid )
sshPort=config.sshport;
}
if (sshConnection)
- sshConnection->disconnectSession();
+ delete sshConnection;
if(currentKey.length()<=0)
{
@@ -3359,10 +3343,8 @@ bool ONMainWindow::startSession ( const QString& sid )
void ONMainWindow::slotListSessions ( bool result,QString output,
- SshProcess* proc )
+ int )
{
- if ( proc )
- delete proc;
if ( result==false )
{
cardReady=false;
@@ -3826,16 +3808,8 @@ void ONMainWindow::startNewSession()
return;
}
- SshProcess* proc=0l;
-
- proc=new SshProcess ( sshConnection, this ) ;
-
-
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
- this,SLOT ( slotRetResumeSess ( bool,
- QString,SshProcess* ) ) );
-
- proc->startNormal ( cmd );
+ sshConnection->executeCommand ( cmd, this, SLOT ( slotRetResumeSess ( bool,
+ QString,int ) ) );
passForm->hide();
}
@@ -4069,14 +4043,8 @@ void ONMainWindow::resumeSession ( const x2goSession& s )
else
cmd += "0";
- SshProcess* proc=0l;
- proc=new SshProcess ( sshConnection, this );
-
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
- this,SLOT ( slotRetResumeSess ( bool, QString,
- SshProcess* ) ) );
-
- proc->startNormal ( cmd );
+ sshConnection->executeCommand ( cmd, this, SLOT ( slotRetResumeSess ( bool, QString,
+ int ) ));
resumingSession=s;
passForm->hide();
}
@@ -4398,6 +4366,7 @@ void ONMainWindow::slotTermSessFromSt()
#ifdef Q_OS_LINUX
if (directRDP)
{
+ x2goDebug<<"terminating direct RDP session";
nxproxy->terminate();
proxyRunning=false;
return;
@@ -4419,10 +4388,8 @@ void ONMainWindow::slotTermSessFromSt()
void ONMainWindow::slotRetSuspSess ( bool result, QString output,
- SshProcess* proc )
+ int )
{
- if ( proc )
- delete proc;
if ( result==false )
{
QString message=tr ( "<b>Connection failed</b>\n" ) +output;
@@ -4515,11 +4482,8 @@ void ONMainWindow::slotNewSess()
void ONMainWindow::slotRetTermSess ( bool result, QString output,
- SshProcess* proc )
+ int )
{
- bool nodel= ( proc==0 );
- if ( proc )
- delete proc;
if ( result==false )
{
QString message=tr ( "<b>Connection failed</b>\n" ) +output;
@@ -4535,7 +4499,7 @@ void ONMainWindow::slotRetTermSess ( bool result, QString output,
}
else
{
- if ( selectSessionDlg->isVisible() &&!nodel )
+ if ( selectSessionDlg->isVisible() )
{
sessTv->model()->removeRow (
sessTv->currentIndex().row() );
@@ -4548,10 +4512,8 @@ void ONMainWindow::slotRetTermSess ( bool result, QString output,
void ONMainWindow::slotRetResumeSess ( bool result,
QString output,
- SshProcess* proc )
+ int )
{
- if ( proc )
- delete proc;
x2goDebug<<"Agent output:"<<output;
if ( result==false )
{
@@ -4738,13 +4700,7 @@ void ONMainWindow::slotRetResumeSess ( bool result,
host=config.server;
resumingSession.server=host;
}
- tunnel=new SshProcess ( sshConnection, this );
- connect ( tunnel,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
- this,SLOT ( slotTunnelFailed ( bool,
- QString,SshProcess* ) ) );
- connect ( tunnel,SIGNAL ( sshTunnelOk() ),
- this,SLOT ( slotTunnelOk() ) );
localGraphicPort=resumingSession.grPort;
int iport=localGraphicPort.toInt() +1000;
@@ -4754,8 +4710,9 @@ void ONMainWindow::slotRetResumeSess ( bool result,
++iport;
localGraphicPort=QString::number ( iport );
- tunnel->startTunnel ( "localhost",resumingSession.grPort.toInt(),"localhost",
- localGraphicPort.toInt() );
+ sshConnection->startTunnel ( "localhost",resumingSession.grPort.toInt(),"localhost",
+ localGraphicPort.toInt(), false, this, SLOT ( slotTunnelOk(int) ), SLOT ( slotTunnelFailed ( bool,
+ QString,int ) ) );
if ( shadowSession )
return;
@@ -4791,9 +4748,8 @@ void ONMainWindow::slotRetResumeSess ( bool result,
"\">> ~/.x2go/C-"+
resumingSession.sessionId+
"/.pulse-client.conf";
- SshProcess* paProc;
- paProc=new SshProcess ( sshConnection, this );
- paProc->startNormal ( scmd );
+
+ sshConnection->executeCommand(scmd);
bool sysPulse=false;
#ifdef Q_OS_LINUX
@@ -4825,18 +4781,20 @@ void ONMainWindow::slotRetResumeSess ( bool result,
}
#endif
if ( sysPulse )
- paProc->start_cp (
+
+ sshConnection->copyFile(
"/var/run/pulse/.pulse-cookie",
"~/.x2go/C-"+
resumingSession.sessionId+
- "/.pulse-cookie" );
+ "/.pulse-cookie", this, SLOT ( slotPCookieReady ( bool, QString,int )));
+
else
{
#ifndef Q_OS_WIN
- paProc->start_cp ( homeDir+"/.pulse-cookie",
- "~/.x2go/C-"+
- resumingSession.sessionId+
- "/.pulse-cookie" );
+ sshConnection->copyFile(homeDir+"/.pulse-cookie",
+ "~/.x2go/C-"+
+ resumingSession.sessionId+
+ "/.pulse-cookie", this, SLOT ( slotPCookieReady ( bool, QString,int )));
#else
QString cooFile=
wapiShortFileName ( homeDir ) +
@@ -4844,41 +4802,25 @@ void ONMainWindow::slotRetResumeSess ( bool result,
QString destFile="~/.x2go/C-"+
resumingSession.sessionId+
"/.pulse-cookie";
- paProc->start_cp ( cooFile,
- destFile );
-
- /*x2goDebug<<"cookie file: "<<cooFile
- <<" remote:"<<
- destFile<<endl;*/
- connect ( paProc,
- SIGNAL (
- sshFinished ( bool,
- QString,
- SshProcess* ) ),
- this,
- SLOT (
- slotPCookieReady ( bool,
- QString,
- SshProcess* )
- ) );
- parecTunnelOk=true;
+ sshConnection->copyFile(cooFile,
+ destFile, this, SLOT ( slotPCookieReady ( bool, QString,int ));
+ parecTunnelOk=true;
#endif
}
}
if ( sndSystem==ESD )
{
- SshProcess* paProc;
- paProc=new SshProcess ( sshConnection, this );
#ifndef Q_OS_WIN
- paProc->start_cp ( homeDir+"/.esd_auth",
- "~/.esd_auth" );
+ sshConnection->copyFile(homeDir+"/.esd_auth",
+ "~/.esd_auth" );
#else
QString cooFile=
wapiShortFileName ( homeDir ) +
"/.x2go/pulse/.esd_auth";
QString destFile="~/.esd_auth";
- paProc->start_cp ( cooFile,
- destFile );
+ sshConnection->copyFile(cooFile,
+ destFile );
+
#endif
}
#ifndef Q_OS_WIN
@@ -4909,32 +4851,21 @@ void ONMainWindow::slotRetResumeSess ( bool result,
#endif //Q_OS_WIN
if ( sshSndTunnel )
{
- sndTunnel=new SshProcess ( sshConnection, this );
-
+ char* okSlot=0;
#ifdef Q_OS_WIN
if ( sndSystem==PULSE )
{
parecTunnelOk=false;
- connect ( sndTunnel,SIGNAL ( sshTunnelOk() ),
- this,SLOT ( slotSndTunOk() ) );
+ okSlot=SLOT ( slotSndTunOk(int) );
}
#endif
- connect ( sndTunnel,SIGNAL ( sshFinished ( bool,
- QString,
- SshProcess* ) ),
- this,SLOT (
- slotSndTunnelFailed ( bool,
- QString,
- SshProcess* ) ) );
-
- sndTunnel->startTunnel (
- "localhost",
- resumingSession.sndPort.toInt(),"127.0.0.1",
- sndPort.toInt(),true );
- /*x2goDebug<<"starting tunnel, local port:"<<
- sndPort<<", remote: "<<
- resumingSession.sndPort<<
- endl;*/
+ sndTunnel=sshConnection->startTunnel (
+ "localhost",
+ resumingSession.sndPort.toInt(),"127.0.0.1",
+ sndPort.toInt(),true,this,okSlot, SLOT (
+ slotSndTunnelFailed ( bool,
+ QString,
+ int ) ));
}
}
}
@@ -4954,7 +4885,7 @@ x2goSession ONMainWindow::getSelectedSession()
}
-void ONMainWindow::slotTunnelOk()
+void ONMainWindow::slotTunnelOk(int)
{
#ifdef Q_OS_WIN
@@ -4980,14 +4911,14 @@ void ONMainWindow::slotTunnelOk()
QMessageBox::Ok,
QMessageBox::NoButton );
slotShowPassForm();
- if ( tunnel )
- delete tunnel;
- if ( sndTunnel )
- delete sndTunnel;
- if ( fsTunnel )
- delete fsTunnel;
- if ( soundServer )
- delete soundServer;
+// if ( tunnel )
+// delete tunnel;
+// if ( sndTunnel )
+// delete sndTunnel;
+// if ( fsTunnel )
+// delete fsTunnel;
+// if ( soundServer )
+// delete soundServer;
tunnel=sndTunnel=fsTunnel=0l;
soundServer=0l;
nxproxy=0l;
@@ -5144,7 +5075,7 @@ void ONMainWindow::slotTunnelOk()
}
void ONMainWindow::slotTunnelFailed ( bool result, QString output,
- SshProcess* )
+ int )
{
if ( result==false )
{
@@ -5156,14 +5087,14 @@ void ONMainWindow::slotTunnelFailed ( bool result, QString output,
QMessageBox::Ok,
QMessageBox::NoButton );
}
- if ( tunnel )
- delete tunnel;
- if ( sndTunnel )
- delete sndTunnel;
- if ( fsTunnel )
- delete fsTunnel;
- if ( soundServer )
- delete soundServer;
+// if ( tunnel )
+// delete tunnel;
+// if ( sndTunnel )
+// delete sndTunnel;
+// if ( fsTunnel )
+// delete fsTunnel;
+// if ( soundServer )
+// delete soundServer;
tunnel=sndTunnel=fsTunnel=0l;
soundServer=0l;
nxproxy=0l;
@@ -5174,7 +5105,7 @@ void ONMainWindow::slotTunnelFailed ( bool result, QString output,
}
void ONMainWindow::slotSndTunnelFailed ( bool result, QString output,
- SshProcess* )
+ int )
{
if ( result==false )
{
@@ -5186,8 +5117,6 @@ void ONMainWindow::slotSndTunnelFailed ( bool result, QString output,
QMessageBox::Ok,
QMessageBox::NoButton );
}
- if ( sndTunnel )
- delete sndTunnel;
sndTunnel=0l;
}
}
@@ -5233,12 +5162,12 @@ void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus )
#endif
if ( closeEventSent )
return;
- if ( tunnel )
- delete tunnel;
- if ( sndTunnel )
- delete sndTunnel;
- if ( fsTunnel )
- delete fsTunnel;
+// if ( tunnel )
+// delete tunnel;
+// if ( sndTunnel )
+// delete sndTunnel;
+// if ( fsTunnel )
+// delete fsTunnel;
if ( soundServer )
delete soundServer;
if ( spoolTimer )
@@ -5306,10 +5235,14 @@ void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus )
#endif
if ( !shadowSession && !usePGPCard && ! ( embedMode &&
( config.checkexitstatus==false ) ) )
+ {
+ x2goDebug<<"checking exit status";
check_cmd_status();
+ }
else
{
- sshConnection->disconnectSession();
+ x2goDebug<<"deleting sshConnection instance: "<<sshConnection;
+ delete sshConnection;
sshConnection=0;
}
if ( startHidden )
@@ -5572,14 +5505,9 @@ void ONMainWindow::slotResumeDoubleClick ( const QModelIndex& )
void ONMainWindow::suspendSession ( QString sessId )
{
- SshProcess* proc=0l;
- proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
- this,SLOT ( slotRetSuspSess ( bool, QString,
- SshProcess* ) ) );
-
- proc->startNormal ( "x2gosuspend-session "+sessId );
+ sshConnection->executeCommand ( "x2gosuspend-session "+sessId, this, SLOT ( slotRetSuspSess ( bool, QString,
+ int ) ) );
}
@@ -5616,14 +5544,8 @@ bool ONMainWindow::termSession ( QString sessId, bool warn )
return true;
}
- SshProcess* proc=0l;
- proc=new SshProcess ( sshConnection, this );
-
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
- this,SLOT ( slotRetTermSess ( bool,
- QString,SshProcess* ) ) );
-
- proc->startNormal ( "x2goterminate-session "+sessId );
+ sshConnection->executeCommand ( "x2goterminate-session "+sessId, this, SLOT ( slotRetTermSess ( bool,
+ QString,int) ) );
proxyRunning=false;
return true;
}
@@ -5868,7 +5790,6 @@ void ONMainWindow::runCommand()
if ( managedMode )
return;
- SshProcess *proc=0l;
QString cmd;
@@ -5916,14 +5837,9 @@ void ONMainWindow::runCommand()
if ( runRemoteCommand )
{
- proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,
- SshProcess* ) ),
- this,SLOT ( slotRetRunCommand ( bool,
- QString,
- SshProcess* ) ) );
-
- proc->startNormal ( cmd );
+ sshConnection->executeCommand ( cmd, this, SLOT ( slotRetRunCommand ( bool,
+ QString,
+ int ) ));
}
#ifdef Q_WS_HILDON
//wait 5 seconds and execute xkbcomp
@@ -5934,18 +5850,15 @@ void ONMainWindow::runCommand()
void ONMainWindow::runApplication(QString exec)
{
- SshProcess* proc=new SshProcess ( sshConnection, this );
- proc->startNormal ("PULSE_CLIENTCONFIG=~/.x2go/C-"+
- resumingSession.sessionId+"/.pulse-client.conf DISPLAY=:"+
- resumingSession.display+
- " setsid "+exec+" 1> /dev/null 2>/dev/null & exit");
+ sshConnection->executeCommand ("PULSE_CLIENTCONFIG=~/.x2go/C-"+
+ resumingSession.sessionId+"/.pulse-client.conf DISPLAY=:"+
+ resumingSession.display+
+ " setsid "+exec+" 1> /dev/null 2>/dev/null & exit");
}
void ONMainWindow::slotRetRunCommand ( bool result, QString output,
- SshProcess* proc )
+ int )
{
- if ( proc )
- delete proc;
if ( result==false )
{
QString message=tr ( "<b>Connection failed</b>\n:\n" ) +output;
@@ -5967,21 +5880,15 @@ void ONMainWindow::slotRetRunCommand ( bool result, QString output,
void ONMainWindow::readApplications()
{
- SshProcess* proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,
- SshProcess* ) ),
- this,SLOT ( slotReadApplications ( bool,
- QString,
- SshProcess* ) ) );
- proc->startNormal ( "x2gogetapps" );
+ sshConnection->executeCommand ( "x2gogetapps", this, SLOT ( slotReadApplications ( bool,
+ QString,
+ int) ));
sbApps->setEnabled(false);
}
void ONMainWindow::slotReadApplications(bool result, QString output,
- SshProcess* proc )
+ int)
{
- if ( proc )
- delete proc;
if ( result==false )
{
QString message=tr ( "<b>Connection failed</b>\n:\n" ) +output;
@@ -6753,11 +6660,8 @@ void ONMainWindow::showHelpPack()
}
void ONMainWindow::slotGetServers ( bool result, QString output,
- SshProcess* proc )
+ int )
{
- if ( proc )
- delete proc;
- proc=0;
if ( result==false )
{
cardReady=false;
@@ -6811,7 +6715,7 @@ void ONMainWindow::slotGetServers ( bool result, QString output,
retSessions=0;
if (sshConnection)
{
- sshConnection->disconnectSession();
+ delete sshConnection;
sshConnection=0;
}
QString passwd;
@@ -6820,7 +6724,7 @@ void ONMainWindow::slotGetServers ( bool result, QString output,
for (int i=0; i< serverSshConnections.count(); ++i)
{
if (serverSshConnections[i])
- serverSshConnections[i]->disconnectSession();
+ delete serverSshConnections[i];
}
serverSshConnections.clear();
for ( int j=0; j<x2goServers.size(); ++j )
@@ -6833,16 +6737,13 @@ void ONMainWindow::slotGetServers ( bool result, QString output,
void ONMainWindow::slotListAllSessions ( bool result,QString output,
- SshProcess* proc )
+ int )
{
bool last=false;
++retSessions;
if ( retSessions == x2goServers.size() )
last=true;
- if ( proc )
- delete proc;
- proc=0;
if ( result==false )
{
@@ -7001,11 +6902,9 @@ void ONMainWindow::exportDirs ( QString exports,bool removable )
if ( startSshFsTunnel() )
return;
}
- SshProcess* lproc;
+
+
QString uname=getCurrentUname();
- lproc=new SshProcess ( sshConnection, this );
- connect ( lproc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotCopyKey ( bool, QString,SshProcess* ) ) );
QString dst=dr.key;
QString dhdir=homeDir+"/.x2go";
#ifdef Q_OS_WIN
@@ -7017,7 +6916,7 @@ void ONMainWindow::exportDirs ( QString exports,bool removable )
dr.isRemovable=removable;
exportDir.append ( dr );
QString keyFile=dr.key;
- lproc->start_cp ( keyFile,dst );
+ sshConnection->copyFile ( keyFile,dst, this, SLOT ( slotCopyKey ( bool, QString,int ) ));
}
@@ -7207,12 +7106,9 @@ QString ONMainWindow::createRSAKey()
return keyName;
}
-void ONMainWindow::slotCopyKey ( bool result, QString output, SshProcess* proc )
+void ONMainWindow::slotCopyKey ( bool result, QString output, int pid)
{
- fsExportKey=proc->getSource();
- if ( proc )
- delete proc;
- proc=0;
+ fsExportKey=sshConnection->getSourceFile(pid);
x2goDebug<<"exported key "<<fsExportKey;
QFile::remove ( fsExportKey );
x2goDebug<<"key removed";
@@ -7254,20 +7150,18 @@ directory* ONMainWindow::getExpDir ( QString key )
void ONMainWindow::slotRetExportDir ( bool result,QString output,
- SshProcess* proc )
+ int pid)
{
QString key;
for ( int i=0; i<exportDir.size(); ++i )
- if ( exportDir[i].proc==proc )
+ if ( exportDir[i].pid==pid )
{
key=exportDir[i].key;
exportDir.removeAt ( i );
break;
}
- if ( proc )
- delete proc;
if ( result==false )
{
@@ -7492,10 +7386,8 @@ void ONMainWindow::slotExportTimer()
for ( int i=0; i<args.size(); ++i )
{
- SshProcess* sproc=new SshProcess (
- sshConnection, this );
- sproc->startNormal ( "export HOSTNAME && x2goumount_session "+
- sessionId+" "+args[i] );
+ sshConnection->executeCommand ( "export HOSTNAME && x2goumount_session "+
+ sessionId+" "+args[i] );
}
}
@@ -8308,20 +8200,13 @@ void ONMainWindow::check_cmd_status()
passwd=getCurrentPass();
x2goDebug<<"check command message"<<endl;
- SshProcess* proc;
- proc=new SshProcess ( sshConnection, this );
- connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
- this,SLOT ( slotCmdMessage ( bool, QString,SshProcess* ) ) );
-
- proc->startNormal ( "x2gocmdexitmessage "+
- resumingSession.sessionId );
+ sshConnection->executeCommand ( "x2gocmdexitmessage "+
+ resumingSession.sessionId , this, SLOT(slotCmdMessage(bool, QString, int)));
}
void ONMainWindow::slotCmdMessage ( bool result,QString output,
- SshProcess* proc )
+ int)
{
- if ( proc )
- delete proc;
if ( result==false )
{
cardReady=false;
@@ -8340,7 +8225,7 @@ void ONMainWindow::slotCmdMessage ( bool result,QString output,
passForm->setEnabled ( true );
pass->setFocus();
pass->selectAll();
- sshConnection->disconnectSession();
+ delete sshConnection;
sshConnection=0;
return;
}
@@ -8353,7 +8238,7 @@ void ONMainWindow::slotCmdMessage ( bool result,QString output,
cmd,QMessageBox::Ok,
QMessageBox::NoButton );
}
- sshConnection->disconnectSession();
+ delete sshConnection;
sshConnection=0;
}
@@ -8378,23 +8263,14 @@ int ONMainWindow::startSshFsTunnel()
QString passwd=getCurrentPass();
QString uname=getCurrentUname();
- fsTunnel=new SshProcess ( sshConnection, this );
-
- connect ( fsTunnel,SIGNAL ( sshFinished ( bool,
- QString,SshProcess* ) ),
- this,SLOT ( slotFsTunnelFailed ( bool,
- QString,SshProcess* ) ) );
-
- connect ( fsTunnel,SIGNAL ( sshTunnelOk() ),
- this,SLOT ( slotFsTunnelOk() ) );
-
- fsTunnel->startTunnel ( "localhost",resumingSession.fsPort.toUInt(),"127.0.0.1",
- clientSshPort.toInt(), true );
+ fsTunnel=sshConnection->startTunnel ( "localhost",resumingSession.fsPort.toUInt(),"127.0.0.1",
+ clientSshPort.toInt(), true, this, SLOT ( slotFsTunnelOk(int)), SLOT ( slotFsTunnelFailed ( bool,
+ QString,int ) ) );
return 0;
}
void ONMainWindow::slotFsTunnelFailed ( bool result, QString output,
- SshProcess* )
+ int)
{
if ( result==false )
{
@@ -8407,15 +8283,13 @@ void ONMainWindow::slotFsTunnelFailed ( bool result, QString output,
QMessageBox::Ok,
QMessageBox::NoButton );
}
- if ( fsTunnel )
- delete fsTunnel;
fsTunnel=0l;
fsTunReady=false;
}
}
-void ONMainWindow::slotFsTunnelOk()
+void ONMainWindow::slotFsTunnelOk(int)
{
fsTunReady=true;
//start reverse mounting if RSA Key and FS tunnel are ready
@@ -8498,7 +8372,6 @@ void ONMainWindow::startX2goMount()
#ifdef Q_OS_WIN
cuser="sshuser";
#endif
- SshProcess* proc=0l;
QString cmd;
QString dirs=dir->dirList;
@@ -8564,14 +8437,9 @@ void ONMainWindow::startX2goMount()
}
}
- proc=new SshProcess ( sshConnection, this );
- dir->proc=proc;
-
- connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
- this,SLOT ( slotRetExportDir ( bool,
- QString,SshProcess* ) ) );
+ dir->pid=sshConnection->executeCommand(cmd,this,SLOT ( slotRetExportDir ( bool,
+ QString,int) ));
- proc->startNormal ( cmd );
}
void ONMainWindow::slotCheckPrintSpool()
@@ -9557,9 +9425,7 @@ void ONMainWindow::slotConfigXinerama()
{
xineramaScreens=newXineramaScreens;
x2goDebug<<"xinerama screen changed, new screens: "<<xineramaScreens<<endl;
- SshProcess* proc=new SshProcess(sshConnection, this);
xineramaTimer->stop();
- connect (proc, SIGNAL(sshFinished(bool,QString,SshProcess*)), this, SLOT(slotXineramaConfigured()));
QStringList screens;
foreach (QRect disp, xineramaScreens)
screens<<QString::number(disp.x())+" "+QString::number(disp.y())+" "+QString::number(disp.width())+
@@ -9568,7 +9434,7 @@ void ONMainWindow::slotConfigXinerama()
resumingSession.sessionId+"/xinerama.conf";
x2goDebug<<cmd<<endl;
- proc->startNormal(cmd);
+ sshConnection->executeCommand(cmd, this, SLOT(slotXineramaConfigured()));
}
}
@@ -10691,7 +10557,6 @@ void ONMainWindow::slotStartParec ()
QTimer::singleShot ( 1000, this, SLOT ( slotStartParec() ) );
return;
}
- SshProcess* paProc;
QString passwd=getCurrentPass();
QString user=getCurrentUname();
QString host=resumingSession.server;
@@ -10700,8 +10565,7 @@ void ONMainWindow::slotStartParec ()
"/.pulse-client.conf "+
"parec 1> /dev/null & sleep 1 && kill %1";
- paProc=new SshProcess ( sshConnection, this );
- paProc->startNormal ( scmd );
+ sshConnection->executeCommand ( scmd );
}
@@ -10713,7 +10577,7 @@ void ONMainWindow::slotSndTunOk()
void ONMainWindow::slotPCookieReady ( bool result,
QString ,
- SshProcess* )
+ int )
{
if ( result )
slotStartParec();
diff --git a/onmainwindow.h b/onmainwindow.h
index 5e8ec6e..ae8ac77 100644
--- a/onmainwindow.h
+++ b/onmainwindow.h
@@ -75,7 +75,6 @@ class QAction;
class QCheckBox;
class QTreeView;
class QModelIndex;
-class SshProcess;
class SshMasterConnection;
class IMGFrame;
class QStandardItemModel;
@@ -100,7 +99,7 @@ struct directory
QString dstKey;
QString dirList;
bool isRemovable;
- SshProcess* proc;
+ int pid;
};
struct serv
@@ -760,9 +759,9 @@ private:
QTextEdit* stInfo;
SVGFrame* ln;
- SshProcess* tunnel;
- SshProcess* sndTunnel;
- SshProcess* fsTunnel;
+ int tunnel;
+ int sndTunnel;
+ int fsTunnel;
QList<x2goSession> selectedSessions;
QStringList selectedDesktops;
x2goSession resumingSession;
@@ -914,7 +913,7 @@ private slots:
void slotChangeKbdLayout(const QString& layout);
void slotSyncX();
void slotShutdownThinClient();
- void slotReadApplications(bool result, QString output, SshProcess* proc );
+ void slotReadApplications(bool result, QString output, int pid );
public slots:
void slotConfig();
@@ -942,24 +941,24 @@ private slots:
void slotGetBrokerAuth();
void slotGetBrokerSession();
void slotCmdMessage ( bool result,QString output,
- SshProcess* );
+ int );
void slotListSessions ( bool result,QString output,
- SshProcess* );
+ int );
void slotRetSuspSess ( bool value,QString message,
- SshProcess* );
+ int );
void slotRetTermSess ( bool result,QString output,
- SshProcess* );
+ int );
void slotRetResumeSess ( bool result,QString output,
- SshProcess* );
+ int );
void slotTunnelFailed ( bool result,QString output,
- SshProcess* );
+ int );
void slotFsTunnelFailed ( bool result,QString output,
- SshProcess* );
+ int );
void slotSndTunnelFailed ( bool result,QString output,
- SshProcess* );
- void slotCopyKey ( bool result,QString output,SshProcess* );
- void slotTunnelOk();
- void slotFsTunnelOk();
+ int );
+ void slotCopyKey ( bool result,QString output,int );
+ void slotTunnelOk(int );
+ void slotFsTunnelOk(int );
void slotProxyError ( QProcess::ProcessError err );
void slotProxyFinished ( int result,QProcess::ExitStatus st );
void slotProxyStderr();
@@ -969,13 +968,13 @@ private slots:
void slotRestartProxy();
void slotTestSessionStatus();
void slotRetRunCommand ( bool result, QString output,
- SshProcess* );
+ int );
void slotGetServers ( bool result, QString output,
- SshProcess* );
+ int );
void slotListAllSessions ( bool result,QString output,
- SshProcess* );
+ int );
void slotRetExportDir ( bool result,QString output,
- SshProcess* );
+ int );
void slotResize();
void slotExportDirectory();
void slotExportTimer();
@@ -1018,7 +1017,7 @@ private slots:
void slotStartParec ();
void slotSndTunOk();
void slotPCookieReady ( bool result,QString output,
- SshProcess* proc );
+ int proc );
void slotEmbedToolBar();
void slotEmbedToolBarToolTip();
void slotHideEmbedToolBarToolTip();
diff --git a/onmainwindow_privat.h b/onmainwindow_privat.h
index 1d6266d..f1a7e4d 100644
--- a/onmainwindow_privat.h
+++ b/onmainwindow_privat.h
@@ -71,7 +71,6 @@
#include <QUrl>
#include <QLocalSocket>
#include <QPlastiqueStyle>
-#include "sshprocess.h"
#include "imgframe.h"
#include <QToolTip>
#include "clicklineedit.h"
diff --git a/sshmasterconnection.cpp b/sshmasterconnection.cpp
index 0bde770..619d2e7 100644
--- a/sshmasterconnection.cpp
+++ b/sshmasterconnection.cpp
@@ -74,6 +74,7 @@ SshMasterConnection::SshMasterConnection (QObject* parent, QString host, int por
tcpNetworkProxy = NULL;
sshProxy= NULL;
sshProxyReady=false;
+ nextPid=0;
breakLoop=false;
this->host=host;
@@ -101,7 +102,9 @@ SshMasterConnection::SshMasterConnection (QObject* parent, QString host, int por
x2goDebug<<"starting ssh connection without kerberos authentication"<<endl;
#endif
kerberos=false;
-
+#ifdef DEBUG
+ x2goDebug<<"SshMasterConnection, instance "<<this<<" created";
+#endif
}
SshMasterConnection::SshMasterConnection (QObject* parent, ONMainWindow* mwd, QString host, int port, bool acceptUnknownServers,
@@ -141,6 +144,9 @@ SshMasterConnection::SshMasterConnection (QObject* parent, ONMainWindow* mwd, QS
reverseTunnel=true;
reverseTunnelRemotePort=remotePort;
mainWnd=mwd;
+#ifdef DEBUG
+ x2goDebug<<"SshMasterConnection, instance "<<this<<" created (reverse tunnel)";
+#endif
}
void SshMasterConnection::slotSshProxyConnectionOk()
@@ -148,19 +154,69 @@ void SshMasterConnection::slotSshProxyConnectionOk()
#ifdef DEBUG
x2goDebug<<"sshproxy connected";
#endif
- SshProcess* tunnel=new SshProcess ( sshProxy, this );
- connect ( tunnel,SIGNAL ( sshFinished ( bool, QString, SshProcess* ) ),
- this,SLOT ( slotSshProxyTunnelFailed(bool,QString,SshProcess*)));
- connect ( tunnel,SIGNAL ( sshTunnelOk() ),
- this,SLOT ( slotSshProxyTunnelOk()) );
localProxyPort=PROXYTUNNELPORT;
while ( ONMainWindow::isServerRunning ( localProxyPort ) )
++localProxyPort;
- tunnel->startTunnel ( host, port, "localhost",localProxyPort);
+ sshProxy->startTunnel ( host, port, "localhost",localProxyPort,false,this, SLOT ( slotSshProxyTunnelOk(int)),
+ SLOT ( slotSshProxyTunnelFailed(bool,QString,int)));
+
+}
+
+int SshMasterConnection::copyFile(const QString& src, const QString dst, QObject* receiver, const char* slotFinished)
+{
+ SshProcess* proc=new SshProcess(this, nextPid++);
+ if(receiver && slotFinished)
+ {
+ connect(proc, SIGNAL(sshFinished(bool,QString,int)), receiver, slotFinished);
+ }
+ proc->start_cp(src,dst);
+ processes<<proc;
+ return proc->pid;
+}
+
+int SshMasterConnection::executeCommand(const QString& command, QObject* receiver, const char* slotFinished)
+{
+ SshProcess* proc=new SshProcess(this, nextPid++);
+ if(receiver && slotFinished)
+ {
+ connect(proc, SIGNAL(sshFinished(bool,QString,int)), receiver, slotFinished);
+ }
+ proc->startNormal(command);
+ processes<<proc;
+ return proc->pid;
+
+}
+
+QString SshMasterConnection::getSourceFile(int pid)
+{
+ foreach (SshProcess* proc, processes)
+ {
+ if(proc->pid==pid)
+ return proc->getSource();
+ }
+ return QString ::null;
+}
+
+
+int SshMasterConnection::startTunnel(const QString& forwardHost, uint forwardPort, const QString& localHost, uint localPort, bool reverse,
+ QObject* receiver, const char* slotTunnelOk, const char* slotFinished)
+{
+ SshProcess* proc=new SshProcess(this, nextPid++);
+ if(receiver && slotFinished)
+ {
+ connect(proc, SIGNAL(sshFinished(bool,QString,int)), receiver, slotFinished);
+ }
+ if(receiver && slotTunnelOk)
+ {
+ connect(proc, SIGNAL(sshTunnelOk(int)), receiver, slotTunnelOk);
+ }
+ proc->startTunnel(forwardHost, forwardPort, localHost, localPort, reverse);
+ processes<<proc;
+ return proc->pid;
}
@@ -182,7 +238,7 @@ void SshMasterConnection::slotSshProxyUserAuthError(QString err)
}
-void SshMasterConnection::slotSshProxyTunnelOk()
+void SshMasterConnection::slotSshProxyTunnelOk(int)
{
#ifdef DEBUG
x2goDebug<<"Ssh proxy tunnel established";
@@ -191,7 +247,7 @@ void SshMasterConnection::slotSshProxyTunnelOk()
}
void SshMasterConnection::slotSshProxyTunnelFailed(bool , QString output,
- SshProcess*)
+ int)
{
breakLoop=true;
emit connectionError(tr("Failed to create SSH proxy tunnel"), output);
@@ -224,6 +280,9 @@ void SshMasterConnection::slotSshProxyServerAuthAborted()
void SshMasterConnection::run()
{
+#ifdef DEBUG
+ x2goDebug<<"SshMasterConnection, instance "<<this<<" entering thread";
+#endif
if(useproxy && proxytype==PROXYSSH && !reverseTunnel)
{
@@ -438,10 +497,23 @@ void SshMasterConnection::run()
SshMasterConnection::~SshMasterConnection()
{
- if (tcpProxySocket != NULL)
- delete tcpProxySocket;
- if (tcpNetworkProxy != NULL)
- delete tcpNetworkProxy;
+ disconnectFlagMutex.lock();
+ disconnectSessionFlag=true;
+ disconnectFlagMutex.unlock();
+#ifdef DEBUG
+ x2goDebug<<"SshMasterConnection, instance "<<this<<" waiting for thread to finish";
+#endif
+ wait();
+#ifdef DEBUG
+ x2goDebug<<"SshMasterConnection, instance "<<this<<" thread finished";
+#endif
+ for(int i=processes.count()-1; i>=0; --i)
+ {
+ delete processes[i];
+ }
+#ifdef DEBUG
+ x2goDebug<<"SshMasterConnection, instance "<<this<<" SshMasterConnection, instance SshMasterConnection(0x7fce7c008aa0) deleted";
+#endif
}
@@ -790,14 +862,6 @@ void SshMasterConnection::addCopyRequest ( SshProcess* creator, QString src, QSt
copyRequestMutex.unlock();
}
-void SshMasterConnection::disconnectSession()
-{
-
- disconnectFlagMutex.lock();
- disconnectSessionFlag=true;
- disconnectFlagMutex.unlock();
-
-}
void SshMasterConnection::copy()
{
@@ -949,8 +1013,7 @@ void SshMasterConnection::channelLoop()
if (useproxy && proxytype==PROXYSSH&&sshProxy)
{
- sshProxy->disconnectSession();
- sshProxy->wait ( 10000 );
+ delete sshProxy;
sshProxy=0;
}
@@ -959,11 +1022,9 @@ void SshMasterConnection::channelLoop()
x2goDebug<<"Disconnecting..."<<endl;
#endif
reverseTunnelConnectionsMutex.lock();
- for ( int i=0; i<reverseTunnelConnections.size(); ++i )
+ for ( int i=reverseTunnelConnections.size()-1; i>=0; --i)
{
- reverseTunnelConnections[i]->disconnectSession();
- reverseTunnelConnections[i]->wait ( 10000 );
-
+ delete reverseTunnelConnections[i];
}
reverseTunnelConnectionsMutex.unlock();
@@ -973,9 +1034,13 @@ void SshMasterConnection::channelLoop()
finalize ( i );
}
channelConnectionsMutex.unlock();
-
ssh_disconnect ( my_ssh_session );
ssh_free ( my_ssh_session );
+
+ if (tcpProxySocket != NULL)
+ delete tcpProxySocket;
+ if (tcpNetworkProxy != NULL)
+ delete tcpNetworkProxy;
#ifdef DEBUG
if ( !reverseTunnel )
x2goDebug<<"All channels closed, session disconnected, quiting session loop"<<endl;
@@ -1219,7 +1284,6 @@ void SshMasterConnection::finalize ( int item )
close ( tcpSocket );
}
SshProcess* proc=channelConnections[item].creator;
- proc->shutdownSocket();
channelConnections.removeAt ( item );
emit channelClosed ( proc );
}
diff --git a/sshmasterconnection.h b/sshmasterconnection.h
index d9e92cf..fa9af03 100644
--- a/sshmasterconnection.h
+++ b/sshmasterconnection.h
@@ -73,9 +73,15 @@ public:
int forwardPort, QString localHost, int localPort, void* channel=0l);
void addChannelConnection(SshProcess* creator, QString cmd);
void addCopyRequest(SshProcess* creator, QString src, QString dst);
- void disconnectSession();
void writeKnownHosts(bool);
void setKeyPhrase(QString);
+
+ int executeCommand(const QString& command, QObject* receiver=0, const char* slotFinished=0);
+ int startTunnel(const QString& forwardHost, uint forwardPort, const QString& localHost,
+ uint localPort, bool reverse=false, QObject* receiver=0, const char* slotTunnelOk=0, const char* slotFinished=0);
+ int copyFile(const QString& src, const QString dst, QObject* receiver=0, const char* slotFinished=0);
+ QString getSourceFile(int pid);
+
void setAcceptUnknownServers(bool accept)
{
acceptUnknownServers=accept;
@@ -128,9 +134,9 @@ private slots:
void slotSshProxyConnectionOk();
- void slotSshProxyTunnelOk();
+ void slotSshProxyTunnelOk(int);
void slotSshProxyTunnelFailed(bool result, QString output,
- SshProcess*);
+ int);
private:
ssh_session my_ssh_session;
@@ -144,6 +150,8 @@ private:
QMutex writeHostKeyMutex;
bool writeHostKey;
bool writeHostKeyReady;
+ int nextPid;
+ QList<SshProcess*> processes;
QString keyPhrase;
bool keyPhraseReady;
diff --git a/sshprocess.cpp b/sshprocess.cpp
index 7050354..c997002 100644
--- a/sshprocess.cpp
+++ b/sshprocess.cpp
@@ -33,7 +33,8 @@
#undef DEBUG
// #define DEBUG
-SshProcess::SshProcess(SshMasterConnection* master, QObject* parent): QObject(parent)
+
+SshProcess::SshProcess(SshMasterConnection* master, int pid): QObject(0)
{
masterCon=master;
serverSocket=0;
@@ -41,6 +42,7 @@ SshProcess::SshProcess(SshMasterConnection* master, QObject* parent): QObject(pa
connect(master,SIGNAL(ioErr(SshProcess*,QString,QString)),this,SLOT(slotIOerr(SshProcess*,QString,QString)));
tunnel=false;
normalExited=true;
+ this->pid=pid;
}
SshProcess::~SshProcess()
@@ -60,21 +62,6 @@ SshProcess::~SshProcess()
}
}
-void SshProcess::shutdownSocket()
-{
- if (serverSocket>0)
- {
-#ifdef Q_OS_WIN
- closesocket(serverSocket);
- WSACleanup();
-
-#else
- close(serverSocket);
-#endif
- serverSocket=0;
-
- }
-}
void SshProcess::slotCheckNewConnection()
{
@@ -111,7 +98,7 @@ void SshProcess::tunnelLoop()
{
QString err=tr("Error creating socket");
x2goDebug<<err<<endl;
- emit sshFinished(false,err,this);
+ emit sshFinished(false,err,pid);
return;
}
#ifndef Q_OS_WIN
@@ -129,7 +116,7 @@ void SshProcess::tunnelLoop()
{
QString err=tr("Error binding ")+localHost+":"+QString::number(localPort);
x2goDebug<<err<<endl;
- emit sshFinished(false,err,this);
+ emit sshFinished(false,err,pid);
return;
}
listen(serverSocket,5);
@@ -137,7 +124,7 @@ void SshProcess::tunnelLoop()
QTimer* timer=new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(slotCheckNewConnection()));
timer->start(100);
- emit sshTunnelOk();
+ emit sshTunnelOk(pid);
#ifdef DEBUG
x2goDebug<<"Direct tunnel: waiting for connections on "<<localHost<<":"<<localPort<<endl;
#endif
@@ -216,20 +203,20 @@ void SshProcess::slotCopyErr(SshProcess* creator, QString message, QString sshSe
{
if (creator!=this)
return;
- emit sshFinished(false, message+" - "+sshSessionErr, this);
+ emit sshFinished(false, message+" - "+sshSessionErr, pid);
}
void SshProcess::slotCopyOk(SshProcess* creator)
{
if (creator!=this)
return;
- emit sshFinished(true,"", this);
+ emit sshFinished(true,"", pid);
}
void SshProcess::slotReverseTunnelOk(SshProcess* creator)
{
if (creator==this)
- emit sshTunnelOk();
+ emit sshTunnelOk(pid);
}
@@ -258,5 +245,5 @@ void SshProcess::slotChannelClosed(SshProcess* creator)
#ifdef DEBUG
x2goDebug<<"ssh finished:"<<normalExited<<" - "<<output<<endl;
#endif
- emit sshFinished(normalExited, output, this);
+ emit sshFinished(normalExited, output, pid);
}
diff --git a/sshprocess.h b/sshprocess.h
index 5b9dad4..9bd8b92 100644
--- a/sshprocess.h
+++ b/sshprocess.h
@@ -29,34 +29,33 @@
#include <netinet/in.h>
#endif
-class SshMasterConnection;
+#include "sshmasterconnection.h"
class SshProcess : public QObject
{
Q_OBJECT
+ friend class SshMasterConnection;
+private:
-public:
- SshProcess(SshMasterConnection* master, QObject* parent=0);
+ SshProcess(SshMasterConnection* master, int pid);
~SshProcess();
-public:
void startNormal(const QString& cmd);
void startTunnel(const QString& forwardHost, uint forwardPort, const QString& localHost,
uint localPort, bool reverse=false);
void start_cp(QString src, QString dst);
- void shutdownSocket();
- QString getSource()
+ QString getSource()
{
return scpSource;
}
-private:
void tunnelLoop();
private:
SshMasterConnection* masterCon;
SshMasterConnection* tunnelConnection;
+ int pid;
QString forwardHost;
QString localHost;
QString command;
@@ -87,11 +86,8 @@ private slots:
void slotCopyOk(SshProcess* creator);
void slotCopyErr(SshProcess* creator,QString message, QString sshSessionErr);
signals:
- void sshFinished ( bool result, QString output, SshProcess* proc);
- void sshTunnelOk();
- /*
- void sudoConfigError ( QString, SshProcess* );
- */
+ void sshFinished ( bool result, QString output, int processId);
+ void sshTunnelOk(int processId);
};
#endif // SSHPROCESS_H
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).