This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 6122d36037f703c81e3936c52e8a17bf6b7820a4 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed May 25 00:56:14 2016 +0200 src/onmainwindow.h: rename ONMainWindow::generateHostDsaKey () to ONMainWindow::generateHostKey () and make key type selectible. Fixes: #1003. Host key type selection currently only works within the code. Replace calls to former ONMainWindow::generateHostDsaKey () with the generalized function and request an RSA-type key. --- debian/changelog | 5 ++++ src/onmainwindow.cpp | 76 +++++++++++++++++++++++++++++++++++++------------- src/onmainwindow.h | 6 ++-- 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/debian/changelog b/debian/changelog index e96500e..7efe994 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,11 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium - src/{onmainwindow,sshmasterconnection}.cpp: refactoring and whitespace only changes following up the #1027 patch. - src/onmainwindow.h: add new enum for selecting SSH host key types. + - src/onmainwindow.h: rename ONMainWindow::generateHostDsaKey () to + ONMainWindow::generateHostKey () and make key type selectible. Fixes: + #1003. Host key type selection currently only works within the code. Replace + calls to former ONMainWindow::generateHostDsaKey () with the generalized + function and request an RSA-type key. [ Mike DePaulo ] * New upstream release (4.0.5.2): diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..e004009 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -8056,14 +8056,14 @@ QString ONMainWindow::createRSAKey() if ( !rsa.open ( QIODevice::ReadOnly | QIODevice::Text ) ) { #if defined (Q_OS_LINUX) || defined (Q_OS_DARWIN) - generateHostDsaKey (); + generateHostKey (RSA_KEY_TYPE); generateEtcFiles (); if (!startSshd ()) { return (QString::null); } - rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_dsa_key.pub" ); + rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_rsa_key.pub" ); rsa.open ( QIODevice::ReadOnly | QIODevice::Text ); #else printSshDError_noHostPubKey(); @@ -9949,7 +9949,7 @@ void ONMainWindow::startWinServers() { dr.mkpath ( etcDir ); - generateHostDsaKey(); + generateHostKey(RSA_KEY_TYPE); generateEtcFiles(); sshStarter->start(); } @@ -10296,27 +10296,63 @@ void ONMainWindow::generateEtcFiles() x2goDebug<<etcDir +"/sshd_config created."; } -void ONMainWindow::generateHostDsaKey() -{ - QString etcDir=homeDir+"/.x2go/etc"; - QDir dr ( homeDir ); - dr.mkpath ( etcDir ); - if ( !QFile::exists ( etcDir+"/ssh_host_dsa_key" ) || - !QFile::exists ( etcDir+"/ssh_host_dsa_key.pub" ) ) - { - - x2goDebug<<"Generating host DSA key."; +void ONMainWindow::generateHostKey(ONMainWindow::key_types key_type) +{ + ONMainWindow::key_types sanitized_key_type = UNKNOWN_KEY_TYPE; + QString stringified_key_type = ""; + switch (key_type) { + case RSA_KEY_TYPE: + sanitized_key_type = key_type; + stringified_key_type = "rsa"; + break; + case DSA_KEY_TYPE: + sanitized_key_type = key_type; + stringified_key_type = "dsa"; + break; + case ECDSA_KEY_TYPE: + sanitized_key_type = key_type; + stringified_key_type = "ecdsa"; + break; + case ED25519_KEY_TYPE: + sanitized_key_type = key_type; + stringified_key_type = "ed25519"; + break; + default: + sanitized_key_type = UNKNOWN_KEY_TYPE; + stringified_key_type = "unknown"; + } + + if (sanitized_key_type == UNKNOWN_KEY_TYPE) { + QMessageBox::critical (this, tr ("Host key type selection error"), + tr ("Unknown host key selected.\nTerminating application.")); + close (); + } + + QString etcDir = homeDir + "/.x2go/etc/"; + QDir dr (homeDir); + dr.mkpath (etcDir); + QString private_key_file = etcDir + "/ssh_host_" + stringified_key_type + "_key"; + QString public_key_file = private_key_file + ".pub"; + + if ((!(QFile::exists (private_key_file))) || (!(QFile::exists (public_key_file)))) + { + x2goDebug << "Generating host key. Type: " << stringified_key_type; #ifdef Q_OS_WIN - QString fname=cygwinPath ( wapiShortFileName ( etcDir ) ) + - "/ssh_host_dsa_key"; -#else - QString fname=etcDir+"/ssh_host_dsa_key"; + private_key_file = cygwinPath (wapiShortFileName (etcDir)) + + "/ssh_host_" + stringified_key_type + "_key"; #endif + QStringList args; - args<<"-t"<<"dsa"<<"-N"<<""<<"-C"<< - "x2goclient DSA host key"<<"-f"<<fname; - QProcess::execute ( "ssh-keygen",args ); + args << "-t" + << stringified_key_type + << "-N" + << "" + << "-C" + << QString ("X2Go Client " + stringified_key_type + "host key") + << "-f" + << private_key_file; + QProcess::execute ("ssh-keygen", args); } } diff --git a/src/onmainwindow.h b/src/onmainwindow.h index 1385cf7..bc70bb1 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -337,13 +337,13 @@ public: ESD }; - enum { + enum key_types { RSA_KEY_TYPE, DSA_KEY_TYPE, ECDSA_KEY_TYPE, ED25519_KEY_TYPE, UNKNOWN_KEY_TYPE - } key_types; + }; static bool debugging; @@ -1204,7 +1204,7 @@ private: #endif void filterDesktops ( const QString& filter, bool strict=false ); - void generateHostDsaKey(); + void generateHostKey(key_types key_type); void generateEtcFiles(); QString u3DataPath(); void cleanPortable(); -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git