[X2Go-Commits] [x2goclient] 234/276: src/onmainwindow.{cpp, h}: reformat generateKey () only.
git-admin at x2go.org
git-admin at x2go.org
Sat Dec 31 01:35:32 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 e4f5bcae3176ef40f099fc6a56aa8bcec5d3a3fc
Author: Mihai Moldovan <ionic at ionic.de>
Date: Sat Sep 24 04:26:47 2016 +0200
src/onmainwindow.{cpp,h}: reformat generateKey () only.
---
debian/changelog | 1 +
src/onmainwindow.cpp | 184 +++++++++++++++++++++++++-------------------------
src/onmainwindow.h | 2 +-
3 files changed, 93 insertions(+), 94 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 95782c3..14ca8d3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -422,6 +422,7 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
checking for validity.
- src/onmainwindow.cpp: use the new functions in generateKey ().
- src/onmainwindow.h: move generateKey () declaration around.
+ - src/onmainwindow.{cpp,h}: reformat generateKey () only.
[ Bernard Cafarelli ]
* New upstream version (4.0.5.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 08205d0..0f53bb4 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -10324,126 +10324,124 @@ std::size_t ONMainWindow::default_size_for_key_type (ONMainWindow::key_types key
return (ret);
}
-QString ONMainWindow::generateKey(ONMainWindow::key_types key_type, bool host_key)
-{
- QString stringified_key_type (key_type_to_string (key_type));
- std::size_t key_bits = default_size_for_key_type (key_type);
+QString ONMainWindow::generateKey (ONMainWindow::key_types key_type, bool host_key) {
+ QString stringified_key_type (key_type_to_string (key_type));
+ std::size_t key_bits = default_size_for_key_type (key_type);
- QString ret ("");
+ QString ret ("");
- QString base_dir (homeDir);
- QString private_key_file ("");
+ QString base_dir (homeDir);
+ QString private_key_file ("");
- if (host_key) {
- base_dir += "/.x2go/etc/";
- }
- else {
- base_dir += "/.x2go/ssh/gen/";
- }
+ if (host_key) {
+ base_dir += "/.x2go/etc/";
+ }
+ else {
+ base_dir += "/.x2go/ssh/gen/";
+ }
- {
- QDir dir (homeDir);
- if (!(dir.mkpath (base_dir))) {
- QMessageBox::critical (this, tr ("SSH key base directory creation error"),
- tr ("Unable to create SSH key base directory '%1'.").arg (base_dir)
- + "\n"
- + tr ("Terminating application."));
- close ();
- }
+ {
+ QDir dir (homeDir);
+ if (!(dir.mkpath (base_dir))) {
+ QMessageBox::critical (this, tr ("SSH key base directory creation error"),
+ tr ("Unable to create SSH key base directory '%1'.").arg (base_dir)
+ + "\n"
+ + tr ("Terminating application."));
+ close ();
}
+ }
#ifdef Q_OS_WIN
- private_key_file = cygwinPath (wapiShortFileName (base_dir));
+ private_key_file = cygwinPath (wapiShortFileName (base_dir));
#else
- private_key_file = base_dir;
+ private_key_file = base_dir;
#endif
- ret = base_dir;
+ ret = base_dir;
- {
- QString tmp_to_add ("");
+ {
+ QString tmp_to_add ("");
- if (host_key) {
- tmp_to_add = "/ssh_host_" + stringified_key_type + "_key";
- }
- else {
- QTemporaryFile temp_file (base_dir + "/key");
- temp_file.open ();
+ if (host_key) {
+ tmp_to_add = "/ssh_host_" + stringified_key_type + "_key";
+ }
+ else {
+ QTemporaryFile temp_file (base_dir + "/key");
+ temp_file.open ();
- /* Extract base name. */
- QFileInfo tmp_file_info (temp_file.fileName ());
- tmp_to_add = tmp_file_info.fileName ();
+ /* Extract base name. */
+ QFileInfo tmp_file_info (temp_file.fileName ());
+ tmp_to_add = tmp_file_info.fileName ();
- /* Clean up again. We don't need the temporary file anymore. */
- temp_file.setAutoRemove (false);
- temp_file.close ();
- temp_file.remove ();
- }
-
- private_key_file += tmp_to_add;
- ret += tmp_to_add;
+ /* Clean up again. We don't need the temporary file anymore. */
+ temp_file.setAutoRemove (false);
+ temp_file.close ();
+ temp_file.remove ();
}
- QString public_key_file (private_key_file + ".pub");
+ private_key_file += tmp_to_add;
+ ret += tmp_to_add;
+ }
- if ((!(QFile::exists (private_key_file))) || (!(QFile::exists (public_key_file))))
- {
- x2goDebug << "Generating SSH key. Type: " << stringified_key_type.toUpper ()
- << "; Location: " << private_key_file;
+ QString public_key_file (private_key_file + ".pub");
- QStringList args;
+ if ((!(QFile::exists (private_key_file))) || (!(QFile::exists (public_key_file)))) {
+ x2goDebug << "Generating SSH key. Type: " << stringified_key_type.toUpper ()
+ << "; Location: " << private_key_file;
- QString comment = "X2Go Client " + stringified_key_type.toUpper () + " ";
+ QStringList args;
- if (host_key) {
- comment += "host";
- }
- else {
- comment += "user";
- }
+ QString comment = "X2Go Client " + stringified_key_type.toUpper () + " ";
- comment += " key";
+ if (host_key) {
+ comment += "host";
+ }
+ else {
+ comment += "user";
+ }
- args << "-t"
- << stringified_key_type
- << "-b"
- << QString::number (key_bits)
- << "-N"
- << ""
- << "-C"
- << comment
- << "-f"
- << private_key_file;
+ comment += " key";
- const int keygen_ret = QProcess::execute ("ssh-keygen", args);
+ args << "-t"
+ << stringified_key_type
+ << "-b"
+ << QString::number (key_bits)
+ << "-N"
+ << ""
+ << "-C"
+ << comment
+ << "-f"
+ << private_key_file;
- if (-2 == keygen_ret) {
- QMessageBox::critical (this, tr ("ssh-keygen launching error"),
- tr ("Unable to start the ssh-keygen binary.")
- + "\n"
- + tr ("Terminating application."));
- close ();
- }
+ const int keygen_ret = QProcess::execute ("ssh-keygen", args);
- if (-1 == keygen_ret) {
- QMessageBox::critical (this, tr ("ssh-keygen crashed"),
- tr ("The ssh-keygen binary crashed.")
- + "\n"
- + tr ("Terminating application."));
- close ();
- }
+ if (-2 == keygen_ret) {
+ QMessageBox::critical (this, tr ("ssh-keygen launching error"),
+ tr ("Unable to start the ssh-keygen binary.")
+ + "\n"
+ + tr ("Terminating application."));
+ close ();
+ }
- if (0 != keygen_ret) {
- QMessageBox::critical (this, tr ("ssh-keygen program error"),
- tr ("The ssh-keygen binary did not exit cleanly.")
- + " "
- + tr ("It was probably called with unknown arguments.")
- + "\n"
- + tr ("Terminating application."));
- close ();
- }
+ if (-1 == keygen_ret) {
+ QMessageBox::critical (this, tr ("ssh-keygen crashed"),
+ tr ("The ssh-keygen binary crashed.")
+ + "\n"
+ + tr ("Terminating application."));
+ close ();
}
- return (ret);
+ if (0 != keygen_ret) {
+ QMessageBox::critical (this, tr ("ssh-keygen program error"),
+ tr ("The ssh-keygen binary did not exit cleanly.")
+ + " "
+ + tr ("It was probably called with unknown arguments.")
+ + "\n"
+ + tr ("Terminating application."));
+ close ();
+ }
+ }
+
+ return (ret);
}
bool ONMainWindow::startSshd()
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index a952da2..83bb902 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -1219,7 +1219,7 @@ private:
key_types check_key_type (key_types key_type);
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 generateKey (key_types key_type, bool host_key = false);
////////////////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