[X2Go-Commits] [x2goclient] 236/281: src/onmainwindow.{cpp, h}: reformat createRSAKey () only.

git-admin at x2go.org git-admin at x2go.org
Thu Jan 19 13:06:06 CET 2017


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

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit 77dff6c2e31109001acb1ecf7bc816373dcc61c6
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Sep 24 04:38:51 2016 +0200

    src/onmainwindow.{cpp,h}: reformat createRSAKey () only.
---
 debian/changelog     |    1 +
 src/onmainwindow.cpp |  129 ++++++++++++++++++++++++--------------------------
 src/onmainwindow.h   |    2 +-
 3 files changed, 64 insertions(+), 68 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4a4af7a..6f3701b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -445,6 +445,7 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
     - src/onmainwindow.h: move generateKey () declaration around.
     - src/onmainwindow.{cpp,h}: reformat generateKey () only.
     - src/onmainwindow.{cpp,h}: move createRSAKey () around.
+    - src/onmainwindow.{cpp,h}: reformat createRSAKey () only.
 
   [ Bernard Cafarelli ]
   * New upstream version (4.0.5.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 59b1393..2e39dc4 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -10395,86 +10395,81 @@ QString ONMainWindow::generateKey (ONMainWindow::key_types key_type, bool host_k
   return (ret);
 }
 
-QString ONMainWindow::createRSAKey()
-{
-    /*
-     * I spent multiple hours on trying to understand this function
-     * and directory exporting in general, so I'd better document
-     * this.
-     *
-     * This function first generates a new RSA private-public key
-     * pair as ~/.x2go/ssh/gen/key.XXXXX{,.pub}.
-     *
-     * Then, the SSH daemon's public host key is read and appended
-     * to the *private* SSH key file after a marker looking like
-     * this: "----BEGIN RSA IDENTITY----"
-     *
-     * Later on, this *private* SSH key file is transferred to the
-     * remote server, which parses it in the "x2gomountdirs" perl
-     * script and extracts the public key (used for logging in
-     * to the client machine) and the public *host* key, used to
-     * circumvent the "untrusted host" message by SSH by
-     * explicitly giving the aforementioned public *host* key as
-     * the only element in a fake "authorized_keys" file. Again,
-     * this is all happening server-side.
-     *
-     * The *public* key part generated here is then taken and
-     * later added to the "authorized_keys" file on the client
-     * side, to allow auto-logins via the generated and transferred
-     * private SSH key.
-     */
+QString ONMainWindow::createRSAKey () {
+  /*
+   * I spent multiple hours on trying to understand this function
+   * and directory exporting in general, so I'd better document
+   * this.
+   *
+   * This function first generates a new RSA private-public key
+   * pair as ~/.x2go/ssh/gen/key.XXXXX{,.pub}.
+   *
+   * Then, the SSH daemon's public host key is read and appended
+   * to the *private* SSH key file after a marker looking like
+   * this: "----BEGIN RSA IDENTITY----"
+   *
+   * Later on, this *private* SSH key file is transferred to the
+   * remote server, which parses it in the "x2gomountdirs" perl
+   * script and extracts the public key (used for logging in
+   * to the client machine) and the public *host* key, used to
+   * circumvent the "untrusted host" message by SSH by
+   * explicitly giving the aforementioned public *host* key as
+   * the only element in a fake "authorized_keys" file. Again,
+   * this is all happening server-side.
+   *
+   * The *public* key part generated here is then taken and
+   * later added to the "authorized_keys" file on the client
+   * side, to allow auto-logins via the generated and transferred
+   * private SSH key.
+   */
 
-    QString user_key = generateKey (RSA_KEY_TYPE);
+  QString user_key = generateKey (RSA_KEY_TYPE);
 
-    /*
-     * Now taking the *host* pub key here...
-     */
-    QFile rsa (homeDir + "/.x2go/etc/ssh_host_rsa_key.pub");
+  /*
+   * Now taking the *host* pub key here...
+   */
+  QFile rsa (homeDir + "/.x2go/etc/ssh_host_rsa_key.pub");
 #ifdef Q_OS_WIN
-    rsa.setFileName (wapiShortFileName (homeDir + "\\.x2go\\etc\\ssh_host_rsa_key.pub"));
+  rsa.setFileName (wapiShortFileName (homeDir + "\\.x2go\\etc\\ssh_host_rsa_key.pub"));
 #endif
 
-    if (!(rsa.open (QIODevice::ReadOnly | QIODevice::Text))) {
-        x2goDebug << "Unable to open public host key file.";
+  if (!(rsa.open (QIODevice::ReadOnly | QIODevice::Text))) {
+    x2goDebug << "Unable to open public host key file.";
 #ifdef Q_OS_UNIX
-        x2goDebug << "Creating a new one.";
-        QString tmp_file_name (generateKey (RSA_KEY_TYPE, true));
-        generateEtcFiles ();
+    x2goDebug << "Creating a new one.";
+    QString tmp_file_name (generateKey (RSA_KEY_TYPE, true));
+    generateEtcFiles ();
 
-        if (!(startSshd ())) {
-            return (QString::null);
-        }
+    if (!(startSshd ())) {
+      return (QString::null);
+    }
 
-        rsa.setFileName (tmp_file_name + ".pub");
-        rsa.open (QIODevice::ReadOnly | QIODevice::Text);
+    rsa.setFileName (tmp_file_name + ".pub");
+    rsa.open (QIODevice::ReadOnly | QIODevice::Text);
 #else
-        printSshDError_noHostPubKey ();
-        return QString::null;
+    printSshDError_noHostPubKey ();
+    return (QString::null);
 #endif
-    }
+  }
 
-    QByteArray rsa_pub;
+  QByteArray rsa_pub;
 
-    if ( !rsa.atEnd() )
-        rsa_pub = rsa.readLine();
-    else
-    {
-        x2goErrorf(9)<<tr("RSA file empty.");
-        return QString::null;
-    }
+  if (!(rsa.atEnd ())) {
+    rsa_pub = rsa.readLine ();
+  else {
+    x2goErrorf (9) << tr ("RSA file empty.");
+    return (QString::null);
+  }
 
-    QFile file ( user_key );
-    if ( !file.open (
-                QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append )
-       )
-    {
-        x2goErrorf(10) << tr ("Cannot open key: ") << user_key;
-        return user_key;
-    }
-    QTextStream out ( &file );
-    out<<"----BEGIN RSA IDENTITY----"<<rsa_pub;
-    file.close();
-    return user_key;
+  QFile file (user_key);
+  if (!(file.open (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))) {
+    x2goErrorf (10) << tr ("Cannot open key: ") << user_key;
+    return (user_key);
+  }
+  QTextStream out (&file);
+  out << "----BEGIN RSA IDENTITY----" << rsa_pub;
+  file.close ();
+  return (user_key);
 }
 
 bool ONMainWindow::startSshd()
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 2df3afa..abfb019 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -1220,7 +1220,7 @@ private:
     QString key_type_to_string (key_types key_type);
     std::size_t default_size_for_key_type (key_types key_type);
     QString generateKey (key_types key_type, bool host_key = false);
-    QString createRSAKeyBundle();
+    QString createRSAKey ();
 
 ////////////////plugin stuff////////////////////
 #ifdef CFGPLUGIN

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