[X2Go-Commits] [x2goclient] 260/267: src/onmainwindow.cpp: fix sshd_config generation on UNIX by searching for the real sftp-server binary path.
git-admin at x2go.org
git-admin at x2go.org
Sat Dec 10 13:36:31 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 06172f05468cfcd73e0cfbe4593fac435b4a5b66
Author: Mihai Moldovan <ionic at ionic.de>
Date: Mon Nov 28 17:38:57 2016 +0100
src/onmainwindow.cpp: fix sshd_config generation on UNIX by searching for the real sftp-server binary path.
---
debian/changelog | 2 ++
src/onmainwindow.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 75 insertions(+), 6 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 460e150..bff7b60 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -473,6 +473,8 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
discovery.
- src/pulsemanager.cpp: refactor PA binary searching code. Less
duplication now.
+ - src/onmainwindow.cpp: fix sshd_config generation on UNIX by searching
+ for the real sftp-server binary path.
[ Bernard Cafarelli ]
* New upstream version (4.0.5.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index d51525d..44ad6f3 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -10152,14 +10152,81 @@ void ONMainWindow::generateEtcFiles()
out<<"StrictModes no\n"<<
"UsePrivilegeSeparation no\n"<<
"PidFile \"" + varDir + "/sshd.pid\"\n" <<
- "AuthorizedKeysFile \"" << authKeyPath << "\"\n" <<
+ "AuthorizedKeysFile \"" << authKeyPath << "\"\n";
#ifdef Q_OS_WIN
- "Subsystem shell "<< wapiShortFileName ( appDir) +"/sh"+"\n"<<
- "Subsystem sftp "<< wapiShortFileName ( appDir) +"/sftp-server"+"\n";
+ out << "Subsystem shell "<< wapiShortFileName ( appDir) +"/sh"+"\n"<<
+ "Subsystem sftp "<< wapiShortFileName ( appDir) +"/sftp-server"+"\n";
#else
- "Subsystem sftp "
- /* This may need some sanitization, i.e., appDir could potentially include whitespace. */
- <<appDir<<"/sftp-server\n";
+ /*
+ * We need to find the sftp-server binary.
+ * This turns out to be surprisingly difficult, because there is no standard place
+ * for this binary. Instead, every distribution installs it where they see fit.
+ * Needless to say, we're screwed...
+ */
+
+ QString sftp_binary;
+
+#if QT_VERSION < 0x050000
+ QProcessEnvironment tmp_env = QProcessEnvironment::systemEnvironment ();
+ QString path_val = tmp_env.value ("PATH");
+
+ QStringList to_back;
+ to_back << "/usr/lib/openssh" /* Debian and Ubuntu */
+ << "/usr/libexec/openssh" /* Fedora, CentOS, hopefully also RHEL */
+ << "/usr/lib/ssh/" /* Mageia, OpenSUSE, SLE{S,D} < 12 x86, SLE{S,D} 12, Arch */
+ << "/usr/lib64/ssh" /* SLE{S,D} < 12 x86_64 */
+ << "/usr/lib/misc" /* Gentoo */
+ << "/usr/libexec"; /* Slackware, OS X */
+
+ add_to_path (path_val, to_back);
+
+ /* Just in case we bundle sftp-server ourselves. */
+ sftp_binary = find_binary (appDir, "sftp-server");
+
+ if (sftp_binary.isEmpty ()) {
+ sftp_binary = find_binary (path_val, "sftp-server");
+ }
+#else /* QT_VERSION < 0x050000 */
+ QStringList search_paths;
+ search_paths << appDir;
+
+ sftp_binary = QStandardPaths::findExecutable ("sftp-binary", search_paths);
+
+ if (sftp_binary.isEmpty ()) {
+ search_paths = QStringList ();
+
+ sftp_binary = QStandardPaths::findExecutable ("sftp-binary", search_paths);
+
+ if (sftp_binary.isEmpty ()) {
+ search_paths = QStringList ();
+ search_paths << "/usr/lib/openssh" /* Debian and Ubuntu */
+ << "/usr/libexec/openssh" /* Fedora, CentOS, hopefully also RHEL */
+ << "/usr/lib/ssh/" /* Mageia, OpenSUSE, SLE{S,D} < 12 x86, SLE{S,D} 12, Arch */
+ << "/usr/lib64/ssh" /* SLE{S,D} < 12 x86_64 */
+ << "/usr/lib/misc" /* Gentoo */
+ << "/usr/libexec"; /* Slackware, OS X */
+
+ sftp_binary = QStandardPaths::findExecutable ("sftp-server", search_paths);
+ }
+ }
+#endif /* QT_VERSION < 0x050000 */
+
+ if (sftp_binary.isEmpty ()) {
+ x2goErrorf (31) << "Unable to find the sftp-server binary. Neither bundled, nor found in $PATH nor additional directories.";
+ show_RichText_ErrorMsgBox (tr ("Unable to find the sftp-server binary. Neither bundled, nor found in $PATH nor additional directories."),
+ tr ("If you are using a Linux-based operating system, please ask your system administrator "
+ "to install the package containing the sftp-server binary. Common names are <b>openssh</b>, "
+ "<b>openssh-server</b> or <b>openssh-sftp-server</b> depending upon distribution.\n\n"
+ "If the sftp-server binary is installed on your system, please report a bug "
+ "mentioning its path on:\n"
+ "<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">"
+ "https://wiki.x2go.org/doku.php/wiki:bugs"
+ "</a></center>\n"),
+ true);
+ abort ();
+ }
+
+ out << "Subsystem sftp " << sftp_binary << "\n";
#endif
/* The log file in startSshd() is specific to Windows. */
--
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