[X2Go-Commits] [x2goclient] 239/267: src/onmainwindow.{cpp, h}: rename createRSAKey () to the more-appropriate name createKeyBundle ().
git-admin at x2go.org
git-admin at x2go.org
Sat Dec 10 13:36:23 CET 2016
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch bugfix/osx
in repository x2goclient.
commit 9945ca7325d58647db5e11f9d0f8b81efab910da
Author: Mihai Moldovan <ionic at ionic.de>
Date: Sat Sep 24 23:12:15 2016 +0200
src/onmainwindow.{cpp,h}: rename createRSAKey () to the more-appropriate name createKeyBundle ().
Also add a key-type parameter and use it to select the required key type
(and maybe generate it if necessary.)
Also use the new functions to get a stringified version of the key type
etc.
---
debian/changelog | 4 ++++
src/onmainwindow.cpp | 30 +++++++++++++++++++-----------
src/onmainwindow.h | 2 +-
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 1013448..e0cd684 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -427,6 +427,10 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
multiple times. Check if the OpenSSH Server is already running and
return true, otherwise try to start it.
- src/onmainwindow.cpp: add some comments only to createRSAKey ().
+ - src/onmainwindow.{cpp,h}: rename createRSAKey () to the more-appropriate
+ name createKeyBundle (). Also add a key-type parameter and use it to
+ select the required key type (and maybe generate it if necessary.) Also
+ use the new functions to get a stringified version of the key type etc.
[ Bernard Cafarelli ]
* New upstream version (4.0.5.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 8fdcb93..c7820ef 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -7928,7 +7928,7 @@ void ONMainWindow::exportDirs ( QString exports,bool removable )
dr.dirList=exports;
- dr.key=createRSAKey();
+ dr.key=createKeyBundle();
// Key creation failure or the like.
if (dr.key.isEmpty ()) {
@@ -10362,7 +10362,7 @@ QString ONMainWindow::generateKey (ONMainWindow::key_types key_type, bool host_k
return (ret);
}
-QString ONMainWindow::createRSAKey () {
+QString ONMainWindow::createKeyBundle (key_types key_type) {
/*
* I spent multiple hours on trying to understand this function
* and directory exporting in general, so I'd better document
@@ -10390,41 +10390,49 @@ QString ONMainWindow::createRSAKey () {
* private SSH key.
*/
- QString user_key = generateKey (RSA_KEY_TYPE);
+ QString stringified_key_type (key_type_to_string (key_type));
+
+ QString user_key = generateKey (key_type);
/*
* Now taking the *host* pub key here...
*/
- QFile rsa (homeDir + "/.x2go/etc/ssh_host_rsa_key.pub");
+ const QString host_pub_key_file_name ("ssh_host_" + stringified_key_type + "_key.pub");
+ QFile rsa (homeDir + "/.x2go/etc/" + host_pub_key_file_name);
#ifdef Q_OS_WIN
- rsa.setFileName (wapiShortFileName (homeDir + "\\.x2go\\etc\\ssh_host_rsa_key.pub"));
+ rsa.setFileName (wapiShortFileName (homeDir + "\\.x2go\\etc\\" + host_pub_key_file_name));
#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));
+ QString tmp_file_name (generateKey (key_type, true));
generateEtcFiles ();
- if (!(startSshd ())) {
+ rsa.setFileName (tmp_file_name + ".pub");
+ if (!(rsa.open (QIODevice::ReadOnly | QIODevice::Text))) {
+ x2goErrorf (9) << tr ("Unable to open newly generated %1 public host key file.").arg (stringified_key_type.toUpper ());
return (QString::null);
}
-
- rsa.setFileName (tmp_file_name + ".pub");
- rsa.open (QIODevice::ReadOnly | QIODevice::Text);
#else
printSshDError_noHostPubKey ();
return (QString::null);
#endif
}
+ if (!(startSshd ())) {
+ x2goDebug << "Failed to start OpenSSH Server pro-actively.";
+ return (QString::null);
+ }
+
QByteArray rsa_pub;
if (!(rsa.atEnd ())) {
rsa_pub = rsa.readLine ();
+ }
else {
- x2goErrorf (9) << tr ("RSA file empty.");
+ x2goErrorf (9) << tr ("%1 public host key file empty.").arg (stringified_key_type.toUpper ());
return (QString::null);
}
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 43b6adc..21e6201 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -1219,7 +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 createRSAKey ();
+ QString createKeyBundle (key_types key_type = RSA_KEY_TYPE);
////////////////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