This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient.
commit 37593ef8b6a9a4d488ead68793d876e94b665086 Author: Mihai Moldovan <io...@ionic.de> Date: Sat Sep 24 04:33:15 2016 +0200 src/onmainwindow.{cpp,h}: move createRSAKey () around. --- debian/changelog | 1 + src/onmainwindow.cpp | 164 +++++++++++++++++++++++++------------------------- src/onmainwindow.h | 2 +- 3 files changed, 84 insertions(+), 83 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6d703c5..dc9dd7c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -417,6 +417,7 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium - src/onmainwindow.cpp: use the new functions in generateKey (). - src/onmainwindow.h: move generateKey () declaration around. - src/onmainwindow.{cpp,h}: reformat generateKey () only. + - src/onmainwindow.{cpp,h}: move createRSAKey () around. -- X2Go Release Manager <git-ad...@x2go.org> Mon, 19 Sep 2016 09:07:07 +0200 diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index fed6c93..b14b28a 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -8070,88 +8070,6 @@ void ONMainWindow::exportDefaultDirs() exportDirs ( dirs.join ( ":" ) ); } -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); - - /* - * 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")); -#endif - - 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 (); - - if (!(startSshd ())) { - return (QString::null); - } - - rsa.setFileName (tmp_file_name + ".pub"); - rsa.open (QIODevice::ReadOnly | QIODevice::Text); -#else - printSshDError_noHostPubKey (); - return QString::null; -#endif - } - - QByteArray rsa_pub; - - 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; -} - void ONMainWindow::slotCopyKey ( bool result, QString output, int pid) { fsExportKey=sshConnection->getSourceFile(pid); @@ -10419,6 +10337,88 @@ 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 user_key = generateKey (RSA_KEY_TYPE); + + /* + * 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")); +#endif + + 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 (); + + if (!(startSshd ())) { + return (QString::null); + } + + rsa.setFileName (tmp_file_name + ".pub"); + rsa.open (QIODevice::ReadOnly | QIODevice::Text); +#else + printSshDError_noHostPubKey (); + return QString::null; +#endif + } + + QByteArray rsa_pub; + + 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; +} + bool ONMainWindow::startSshd() { if ( embedMode && config.confFS && !config.useFs ) diff --git a/src/onmainwindow.h b/src/onmainwindow.h index ed9fb71..41a2d6f 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -955,7 +955,6 @@ private: bool soundParameter ( QString val ); void printError ( QString param ); void exportDefaultDirs(); - QString createRSAKey(); directory* getExpDir ( QString key ); bool findInList ( const QString& uid ); void setUsersEnabled ( bool enable ); @@ -1220,6 +1219,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(); ////////////////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 _______________________________________________ x2go-commits mailing list x2go-commits@lists.x2go.org http://lists.x2go.org/listinfo/x2go-commits