This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2goclient. from 65c4ada Revert "add build dependencies for qt5" new 4ae8b90 src/sshmasterconnection: send EOF before closing channel. new e9885b3 src/sshmasterconnection: return false if login check remote command execution failed. new 221899d src/sshmasterconnection: refactor some of the channel loop and fix channel/session closes. new 7a58037 src/sshmasterconnection: fix 'when not' password auth. new 0982f8f src/sshmasterconnection: correct retval check. new f101331 src/sshmasterconnection: explicitly mark function parameters as unused. new 56d82b9 .gitignore: ignore Visual Studio temporary files. Fixes: #1469. The 7 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 3 + debian/changelog | 13 ++ src/sshmasterconnection.cpp | 285 ++++++++++++++++++++++++-------------------- 3 files changed, 174 insertions(+), 127 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 7a58037568dc37a7012d772324416a8ade4a7a3f Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 09:24:03 2020 +0200 src/sshmasterconnection: fix 'when not' password auth. Avoids double error messages. --- debian/changelog | 2 ++ src/sshmasterconnection.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e4342a7..fe0109d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium execution failed. - src/sshmasterconnection: refactor some of the channel loop and fix channel/session closes. + - src/sshmasterconnection: fix 'when not' password auth. Avoids double + error messages. -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 68d6047..932c7d5 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -1260,7 +1260,7 @@ bool SshMasterConnection::userAuthWithPass() } } - if ((!ret) && (method & ~SSH_AUTH_METHOD_PASSWORD)) { + if ((!ret) && (!(method & SSH_AUTH_METHOD_PASSWORD))) { /* In case password auth is disabled, make sure the error message is not empty. */ QString err = ssh_get_error (my_ssh_session); authErrors << err; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 0982f8ff7f757a8b2ea2a8054082f348db2466c7 Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 09:26:55 2020 +0200 src/sshmasterconnection: correct retval check. --- debian/changelog | 1 + src/sshmasterconnection.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index fe0109d..067358b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,7 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium channel/session closes. - src/sshmasterconnection: fix 'when not' password auth. Avoids double error messages. + - src/sshmasterconnection: correct retval check. -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 932c7d5..9a4fd6f 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -1988,8 +1988,7 @@ void SshMasterConnection::channelLoop() delete [] read_chan; delete [] out_chan; - if ( retval == -1 ) - { + if (SSH_OK != retval) { x2goDebug<<"select() error."; continue; } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit e9885b377de71b0364490fe257c36a3c9ee2b0e2 Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 08:42:31 2020 +0200 src/sshmasterconnection: return false if login check remote command execution failed. --- debian/changelog | 2 ++ src/sshmasterconnection.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index 75cb2ba..98ff8ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium [ Melroy van den Berg ] * New upstream version (4.1.2.3): - src/sshmasterconnection: send EOF before closing channel. + - src/sshmasterconnection: return false if login check remote command + execution failed. -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 7adf5d2..30f9a10 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -1686,6 +1686,7 @@ bool SshMasterConnection::checkLogin() QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_request_exec"); x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; ssh_channel_free(channel); + return false; } else { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit f1013314b88769dec38a9ebdd0e63b5e6119e03b Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 09:35:22 2020 +0200 src/sshmasterconnection: explicitly mark function parameters as unused. --- debian/changelog | 1 + src/sshmasterconnection.cpp | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 067358b..32a5550 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,7 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium - src/sshmasterconnection: fix 'when not' password auth. Avoids double error messages. - src/sshmasterconnection: correct retval check. + - src/sshmasterconnection: explicitly mark function parameters as unused. -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 9a4fd6f..3f9dc25 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -435,19 +435,16 @@ int SshMasterConnection::startTunnel(const QString& forwardHost, uint forwardPor return proc->pid; } -void SshMasterConnection::slotSshProxyInteractionFinish(SshMasterConnection* connection) -{ +void SshMasterConnection::slotSshProxyInteractionFinish (SshMasterConnection* connection /* unused */) { x2goDebug<<"SSH proxy interaction finished"; slotSshProxyUserAuthError("NO_ERROR"); } -void SshMasterConnection::slotSshProxyInteractionStart(SshMasterConnection* connection, QString prompt) -{ +void SshMasterConnection::slotSshProxyInteractionStart (SshMasterConnection* connection /* unused */, QString prompt) { emit startInteraction(this, prompt); } -void SshMasterConnection::slotSshProxyInteractionUpdate(SshMasterConnection* connection, QString output) -{ +void SshMasterConnection::slotSshProxyInteractionUpdate (SshMasterConnection* connection /* unused */, QString output) { emit updateInteraction(this, output); } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 56d82b912b3b92508fe21035e075dc879691f5dc Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 09:38:47 2020 +0200 .gitignore: ignore Visual Studio temporary files. Fixes: #1469. --- .gitignore | 3 +++ debian/changelog | 1 + 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index eafee6a..f056957 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ x2goclient.pro.user # This file. .gitignore + +# Generated by Visual Studio. +.vscode/ diff --git a/debian/changelog b/debian/changelog index 32a5550..21abcc1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,7 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium error messages. - src/sshmasterconnection: correct retval check. - src/sshmasterconnection: explicitly mark function parameters as unused. + - .gitignore: ignore Visual Studio temporary files. Fixes: #1469. -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 221899d12c302f517384d28351019bc19d203007 Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 09:14:04 2020 +0200 src/sshmasterconnection: refactor some of the channel loop and fix channel/session closes. --- debian/changelog | 2 + src/sshmasterconnection.cpp | 268 +++++++++++++++++++++++++------------------- 2 files changed, 153 insertions(+), 117 deletions(-) diff --git a/debian/changelog b/debian/changelog index 98ff8ed..e4342a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium - src/sshmasterconnection: send EOF before closing channel. - src/sshmasterconnection: return false if login check remote command execution failed. + - src/sshmasterconnection: refactor some of the channel loop and fix + channel/session closes. -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 30f9a10..68d6047 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -58,6 +58,9 @@ const QString SshMasterConnection::challenge_auth_code_prompts_[] = { }; +static bool SshMasterConnection::createChannelConnection (int i, int &maxsock, fd_set &rfds, ssh_channel *read_chan); + + #ifdef Q_OS_WIN #include <QSettings> // parse known_hosts file from libssh and export keys in registry to use with plink.exe @@ -555,6 +558,7 @@ void SshMasterConnection::run() #endif } + /* Set time-out to 1 min. */ long timeout = 60; my_ssh_session = ssh_new(); @@ -857,6 +861,7 @@ bool SshMasterConnection::sshConnect() work_port = inferred_port & 0xFFFF; + ssh_disconnect (tmp_session); ssh_free (tmp_session); } } @@ -1970,124 +1975,13 @@ void SshMasterConnection::channelLoop() for ( int i=0; i<channelConnections.size(); ++i ) { - int tcpSocket=channelConnections.at ( i ).sock; - if ( tcpSocket>0 ) - FD_SET ( tcpSocket, &rfds ); - if ( channelConnections.at ( i ).channel==0l ) - { - x2goDebug<<"Creating new channel."<<endl; - ssh_channel channel = ssh_channel_new ( my_ssh_session ); - - if (!channel) { - QString err = ssh_get_error (my_ssh_session); - /*: Argument in this context will be a function name. */ - QString error_msg = tr ("%1 failed.").arg ("ssh_channel_new"); - emit ioErr (channelConnections[i].creator, error_msg, err); - - x2goDebug << error_msg.left (error_msg.size () - 1) << ": " << err << endl; - - continue; - } - x2goDebug<<"New channel:"<<channel<<endl; - channelConnections[i].channel=channel; - if ( tcpSocket>0 ) - { - x2goDebug << "Forwarding parameters: from remote (" << channelConnections.at (i).forwardHost << ":" - << channelConnections.at (i).forwardPort << ") to local (" - << channelConnections.at (i).localHost << ":" << channelConnections.at (i).localPort - << ")"; - - /* - * Cannot support config file parsing here with pre-0.6.0 libssh versions. - * There's just no way to get the inferred host and port values. - */ -#if LIBSSH_VERSION_INT >= SSH_VERSION_INT (0, 6, 0) - ssh_session tmp_session = ssh_new (); - - if (!tmp_session) { - QString error_msg = tr ("Cannot create SSH session."); - x2goDebug << error_msg; - emit ioErr (channelConnections[i].creator, error_msg, ""); - } - else { - QByteArray tmp_BA = channelConnections.at (i).forwardHost.toLocal8Bit (); - const int tmp_port = channelConnections.at (i).forwardPort; - - ssh_options_set (tmp_session, SSH_OPTIONS_HOST, tmp_BA.data ()); - - if (tmp_port) { - ssh_options_set (tmp_session, SSH_OPTIONS_PORT, &tmp_port); - } - - /* The host and port might be a shorthand and zero, so fetch the actual data. */ - if (ssh_options_parse_config (tmp_session, NULL) < 0) { - x2goDebug << "Warning: unable to parse the SSH config file."; - } - - unsigned int inferred_port = 0; - ssh_options_get_port (tmp_session, &inferred_port); - x2goDebug << "Temporary session port after config file parse: " << inferred_port; - - char *inferred_host = NULL; - ssh_options_get (tmp_session, SSH_OPTIONS_HOST, &inferred_host); - x2goDebug << "Temporary session host after config file parse: " << inferred_host; - - channelConnections[i].forwardHost = QString (inferred_host); - channelConnections[i].forwardPort = static_cast<int> (inferred_port); - - ssh_string_free_char (inferred_host); - ssh_free (tmp_session); - } -#endif - - { - QByteArray tmp_BA_forward = channelConnections.at (i).forwardHost.toLocal8Bit (); - QByteArray tmp_BA_local = channelConnections.at (i).localHost.toLocal8Bit (); - - if ( ssh_channel_open_forward ( channel, - tmp_BA_forward.data (), - channelConnections.at ( i ).forwardPort, - tmp_BA_local.data (), - channelConnections.at ( i ).localPort ) != SSH_OK ) - { - QString err=ssh_get_error ( my_ssh_session ); - QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_open_forward"); - emit ioErr ( channelConnections[i].creator, errorMsg, err ); - x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; - } - else - { - x2goDebug<<"New channel forwarded."<<endl; - } - } - } - else - { - x2goDebug<<"Executing remote: "<<channelConnections.at ( i ).command<<endl; - if ( ssh_channel_open_session ( channel ) !=SSH_OK ) - { - QString err=ssh_get_error ( my_ssh_session ); - QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_open_session"); - emit ioErr ( channelConnections[i].creator, errorMsg, err ); - x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; - } - else if ( ssh_channel_request_exec ( channel, channelConnections[i].command.toLatin1() ) != SSH_OK ) - { - QString err=ssh_get_error ( my_ssh_session ); - QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_request_exec"); - emit ioErr ( channelConnections[i].creator, errorMsg, err ); - x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; - } - else - { - x2goDebug<<"New exec channel created."<<endl; - } - } - + // Try to make a channel connection + // TODO: Mabye a retry? + bool res = createChannelConnection (i, maxsock, rfds, read_chan); + if (!(res)) { + x2goDebug << "Connection to channel went wrong."; + continue; } - read_chan[i]=channelConnections.at ( i ).channel; - if ( tcpSocket>maxsock ) - maxsock=tcpSocket; } channelConnectionsMutex.unlock(); retval=ssh_select ( read_chan,out_chan,maxsock+1,&rfds,&tv ); @@ -2213,6 +2107,146 @@ void SshMasterConnection::channelLoop() } } +/** + * Create SSH channel connection (used within a loop of channels) + */ +static bool SshMasterConnection::createChannelConnection (int i, int &maxsock, fd_set &rfds, ssh_channel *read_chan) { + int tcpSocket=channelConnections.at ( i ).sock; + if ( tcpSocket>0 ) + FD_SET ( tcpSocket, &rfds ); + if ( channelConnections.at ( i ).channel==0l ) + { + x2goDebug<<"Creating new channel."<<endl; + ssh_channel channel = ssh_channel_new ( my_ssh_session ); + + if (!channel) { + QString err = ssh_get_error (my_ssh_session); + /*: Argument in this context will be a function name. */ + QString error_msg = tr ("%1 failed.").arg ("ssh_channel_new"); + emit ioErr (channelConnections[i].creator, error_msg, err); + + x2goDebug << error_msg.left (error_msg.size () - 1) << ": " << err << endl; + + return (false); + } + x2goDebug<<"New channel:"<<channel<<endl; + channelConnections[i].channel=channel; + if ( tcpSocket>0 ) + { + x2goDebug << "Forwarding parameters: from remote (" << channelConnections.at (i).forwardHost << ":" + << channelConnections.at (i).forwardPort << ") to local (" + << channelConnections.at (i).localHost << ":" << channelConnections.at (i).localPort + << ")"; + + /* + * Cannot support config file parsing here with pre-0.6.0 libssh versions. + * There's just no way to get the inferred host and port values. + */ +#if LIBSSH_VERSION_INT >= SSH_VERSION_INT (0, 6, 0) + ssh_session tmp_session = ssh_new (); + + if (!tmp_session) { + QString error_msg = tr ("Cannot create SSH session."); + x2goDebug << error_msg; + emit ioErr (channelConnections[i].creator, error_msg, ""); + } + else { + QByteArray tmp_BA = channelConnections.at (i).forwardHost.toLocal8Bit (); + const int tmp_port = channelConnections.at (i).forwardPort; + + ssh_options_set (tmp_session, SSH_OPTIONS_HOST, tmp_BA.data ()); + + if (tmp_port) { + ssh_options_set (tmp_session, SSH_OPTIONS_PORT, &tmp_port); + } + + /* The host and port might be a shorthand and zero, so fetch the actual data. */ + if (ssh_options_parse_config (tmp_session, NULL) < 0) { + x2goDebug << "Warning: unable to parse the SSH config file."; + } + + unsigned int inferred_port = 0; + ssh_options_get_port (tmp_session, &inferred_port); + x2goDebug << "Temporary session port after config file parse: " << inferred_port; + + char *inferred_host = NULL; + ssh_options_get (tmp_session, SSH_OPTIONS_HOST, &inferred_host); + x2goDebug << "Temporary session host after config file parse: " << inferred_host; + + channelConnections[i].forwardHost = QString (inferred_host); + channelConnections[i].forwardPort = static_cast<int> (inferred_port); + + ssh_string_free_char (inferred_host); + ssh_free (tmp_session); + } +#endif + + { + QByteArray tmp_BA_forward = channelConnections.at (i).forwardHost.toLocal8Bit (); + QByteArray tmp_BA_local = channelConnections.at (i).localHost.toLocal8Bit (); + + if ( ssh_channel_open_forward ( channel, + tmp_BA_forward.data (), + channelConnections.at ( i ).forwardPort, + tmp_BA_local.data (), + channelConnections.at ( i ).localPort ) != SSH_OK ) + { + QString err=ssh_get_error ( my_ssh_session ); + QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_open_forward"); + emit ioErr ( channelConnections[i].creator, errorMsg, err ); + x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; + } + else + { + x2goDebug<<"New channel forwarded."<<endl; + } + } + } + else + { + x2goDebug<<"Executing remote: "<<channelConnections.at ( i ).command<<endl; + if ( ssh_channel_open_session ( channel ) !=SSH_OK ) + { + QString err=ssh_get_error ( my_ssh_session ); + QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_open_session"); + + /* Free channel. */ + ssh_channel_free (channel); + + emit ioErr ( channelConnections[i].creator, errorMsg, err ); + x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; + + return (false); + } + else if ( ssh_channel_request_exec ( channel, channelConnections[i].command.toLatin1() ) != SSH_OK ) + { + QString err=ssh_get_error ( my_ssh_session ); + QString errorMsg=tr ( "%1 failed." ).arg ("ssh_channel_request_exec"); + + /* Close connection and free channel. */ + ssh_channel_close (channel); + ssh_channel_free (channel); + + emit ioErr ( channelConnections[i].creator, errorMsg, err ); + x2goDebug<<errorMsg.left (errorMsg.size () - 1)<<": "<<err<<endl; + + return (false); + } + else + { + /* Everything is OK. */ + x2goDebug<<"New exec channel created."<<endl; + } + } + } + + read_chan[i]=channelConnections.at ( i ).channel; + if ( tcpSocket>maxsock ) + maxsock=tcpSocket; + + return (true); +} + void SshMasterConnection::finalize ( int item ) { int tcpSocket=channelConnections.at ( item ).sock; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 4ae8b905e350deff8440ff4077be8f001781c6e9 Author: Melroy van den Berg <melroy@melroy.org> Date: Wed May 20 08:38:44 2020 +0200 src/sshmasterconnection: send EOF before closing channel. --- debian/changelog | 4 ++++ src/sshmasterconnection.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index bcf48fa..75cb2ba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,10 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium * New upstream version (4.1.2.3): - x2goclient.pro: use the right C++ standard library on OS X/macOS. + [ Melroy van den Berg ] + * New upstream version (4.1.2.3): + - src/sshmasterconnection: send EOF before closing channel. + -- X2Go Release Manager <git-admin@x2go.org> Thu, 13 Feb 2020 12:31:20 +0100 x2goclient (4.1.2.2-0x2go1) unstable; urgency=medium diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp index 8b59fe7..7adf5d2 100644 --- a/src/sshmasterconnection.cpp +++ b/src/sshmasterconnection.cpp @@ -1753,8 +1753,8 @@ bool SshMasterConnection::checkLogin() sshProcErrString=tr("Reconnect session"); x2goDebug<<"Reconnect session"; } - ssh_channel_close(channel); ssh_channel_send_eof(channel); + ssh_channel_close(channel); ssh_channel_free(channel); return retVal; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git