[X2Go-Commits] [x2goclient] 04/05: sshmasterconnection.cpp: port QProcess::start () change.

git-admin at x2go.org git-admin at x2go.org
Thu Jun 11 04:23:22 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit 6b163ca1783a4c2e66a0f6dcc049d7c0a8599039
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Thu Jun 11 03:47:01 2015 +0200

    sshmasterconnection.cpp: port QProcess::start () change.
---
 debian/changelog            |    1 +
 src/sshmasterconnection.cpp |   52 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 16df554..79ef02d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -61,6 +61,7 @@ x2goclient (4.0.4.1-0x2go1) UNRELEASED; urgency=low
     - sshprocess.cpp: add a bit more debugging - also print out the unmodified
       raw output of SSH commands.
     - onmainwindow.cpp: remove now-bogus double quote escaping.
+    - sshmasterconnection.cpp: port QProcess::start () change.
 
  -- X2Go Release Manager <git-admin at x2go.org>  Tue, 26 May 2015 21:42:09 +0200
 
diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp
index bae0410..78d4564 100644
--- a/src/sshmasterconnection.cpp
+++ b/src/sshmasterconnection.cpp
@@ -1137,25 +1137,61 @@ bool SshMasterConnection::userAuthWithKey()
 bool SshMasterConnection::userAuthKrb()
 {
     QProcess ssh;
-    QString sshCmd;
 
     QUuid uuid = QUuid::createUuid();
     QString uuidStr = uuid.toString().mid(1, 36).toLower();
 
-    QString shcmd = "sh -c 'echo X2GODATABEGIN:" + uuidStr + "; whoami; echo X2GODATAEND:" + uuidStr +";'";
+    /* On Windows, arguments are automatically wrapped in double quotes.
+     * Additionally, QProcess automatically doubles escape characters before
+     * double quotes and inserts an escape character before any non-escaped
+     * double quotes.
+     * Thus, we don't escape double quotes here and let Qt handle this stuff.
+     *
+     * On UNIX-like platforms, likewise, we MUST NOT escape double quotes,
+     * as there is no preceding "outer double quote" the whole argument
+     * is wrapped in.
+     */
+    QString shcmd = "bash -c 'echo \"X2GODATABEGIN:" + uuidStr + "\"; whoami; echo \"X2GODATAEND:" + uuidStr + "\";'";
+
+    QString local_cmd = "";
+    QStringList local_args;
 
 #ifdef Q_OS_WIN
-    sshCmd="plink -batch "+user+"@"+host+" -P "+
-           QString::number(port)+ " "+shcmd;
+    local_cmd = "plink";
+
+    /* General options. */
+    local_args << "-batch";
+
+    /* Port option. Must be the last one added! */
+    local_args << "-P";
 #else
-    sshCmd="ssh -o GSSApiAuthentication=yes "+user+"@"+host+" -p "+
-           QString::number(port)+ " -o PasswordAuthentication=no -o PubkeyAuthentication=no "+shcmd;
+    local_cmd = "ssh";
+
+    /* Kerberos options. */
+    local_args << "-o" << "GSSApiAuthentication=yes"
+               << "-o" << "PasswordAuthentication=no"
+               << "-o" << "PubkeyAuthentication=no";
+
+    /* Port option. Must be the last one added! */
+    local_args << "-p";
 #endif
+    local_args << QString::number (port)
+               << "-l" << user
+               << host;
+
+    /* On Windows, arguments are automatically wrapped in double quotes.
+     * This means we do not have to wrap shcmd ourselves.
+     *
+     * On UNIX-like platforms, we likewise MUST NOT wrap the command in
+     * double quotes, as each entry in the arguments list is passed as
+     * one entry in argv.
+     */
+    local_args << shcmd;
 
 #ifdef DEBUG
-    x2goDebug<<"Starting ssh:" <<sshCmd<<endl;
+    x2goDebug << "Starting ssh:" << local_cmd << " " << local_args.join (" ") << endl;
 #endif
-    ssh.start(sshCmd);
+    ssh.start (local_cmd, local_args);
 
 
     if (!ssh.waitForStarted(5000))

--
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