This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit eaefda1251e9df31f672071caf78319d9d4bc0ec Author: Mihai Moldovan <ionic@ionic.de> Date: Fri Sep 23 04:47:22 2016 +0200 src/{onmainwindow.{cpp,h},configdialog.cpp}: remove userSshd variable and code related to non-user-mode-sshd setups. Simplifies code a bit and we want to always start a user-mode OpenSSH server anyway. Also get rid of the clientport variable that is now unnecessary. --- debian/changelog | 4 + src/configdialog.cpp | 20 ----- src/onmainwindow.cpp | 236 ++++++++++---------------------------------------- src/onmainwindow.h | 1 - 4 files changed, 49 insertions(+), 212 deletions(-) diff --git a/debian/changelog b/debian/changelog index 294ab97..25b38b4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -395,6 +395,10 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium - src/onmainwindow.cpp: add more error handling to generateKey () and fix up a broken error-handling section. - src/onmainwindow.cpp: fix up a few debug strings. + - src/{onmainwindow.{cpp,h},configdialog.cpp}: remove userSshd variable + and code related to non-user-mode-sshd setups. Simplifies code a bit and + we want to always start a user-mode OpenSSH server anyway. Also get rid + of the clientport variable that is now unnecessary. -- X2Go Release Manager <git-admin@x2go.org> Mon, 19 Sep 2016 09:07:07 +0200 diff --git a/src/configdialog.cpp b/src/configdialog.cpp index d1973d0..9e771d5 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -248,22 +248,6 @@ ConfigDialog::ConfigDialog ( QWidget * parent, Qt::WindowFlags f ) #endif //Q_OS_DARWIN -#ifndef Q_OS_WIN - clientSshPort=new QSpinBox ( fr ); - clientSshPort->setMaximum ( 1000000 ); - clientSshPort->setValue ( st.setting()->value ( "clientport", - ( QVariant ) 22 ).toInt() ); - - QHBoxLayout* sshLay=new QHBoxLayout(); - sshLay->addWidget ( - new QLabel ( tr ( - "Clientside (local) SSH daemon port for file system export usage:" - ),fr ) ); - sshLay->addWidget ( clientSshPort ); - sshLay->addStretch(); - frLay->addLayout ( sshLay ); -#endif - if ( embedMode ) { cbStartEmbed=new QCheckBox ( @@ -411,10 +395,6 @@ void ConfigDialog::slot_accepted() st.setting()->setValue ( "xdarwin/directory", ( QVariant ) leXexec->text() ); #endif -#ifndef Q_OS_WIN - st.setting()->setValue ( "clientport", - ( QVariant ) clientSshPort->value() ); -#endif pwid->saveSettings(); if ( embedMode ) diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 7d70eb1..e9a9f92 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -151,7 +151,6 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) X2goSettings st ( "settings" ); winSshdStarted=false; #else - userSshd=false; sshd=0l; #endif @@ -1516,7 +1515,7 @@ void ONMainWindow::closeClient() #endif /* defined (Q_OS_DARWIN) || defined (Q_OS_WIN) */ #ifndef Q_OS_WIN - if ( userSshd && sshd ) + if (sshd) { x2goDebug<<"Terminating the OpenSSH server ..."; sshd->terminate(); @@ -1645,11 +1644,6 @@ void ONMainWindow::loadSettings() ldapPort2=st1.setting()->value ( "LDAP/port2", ( QVariant ) 0 ).toInt(); } -#ifndef Q_OS_WIN - if ( !userSshd ) - clientSshPort=st1.setting()->value ( "clientport", - ( QVariant ) 22 ).toString(); -#endif showToolBar=st1.setting()->value ( "toolbar/show", ( QVariant ) true ).toBool(); @@ -8088,52 +8082,26 @@ QString ONMainWindow::createRSAKey() /* * Now taking the *host* pub key here... */ - QFile rsa ( "/etc/ssh/ssh_host_rsa_key.pub" ); + QFile rsa (homeDir + "/.x2go/etc/ssh_host_rsa_key.pub"); #ifdef Q_OS_WIN - rsa.setFileName ( - wapiShortFileName ( - homeDir+"\\.x2go\\etc\\ssh_host_dsa_key.pub" ) ); -#else - if ( userSshd ) - rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_dsa_key.pub" ); - + rsa.setFileName (wapiShortFileName (homeDir + "\\.x2go\\etc\\ssh_host_rsa_key.pub")); #endif -#ifdef Q_OS_DARWIN - { - /* OS X 10.11+ changed the key location to /etc/ssh/. */ - QFileInfo rsa_host_key ("/etc/ssh/ssh_host_rsa_key.pub"); - - x2goDebug << "first try for RSA key " << rsa_host_key.absoluteFilePath () << ": " - << rsa_host_key.exists (); - if (!(rsa_host_key.exists ())) { - rsa_host_key = QFileInfo ("/etc/ssh_host_rsa_key.pub"); - - x2goDebug << "second try for RSA key " << rsa_host_key.absoluteFilePath () << ": " - << rsa_host_key.exists (); - if (!(rsa_host_key.exists ())) { - printSshDError_noHostPubKey (); - return QString::null; - } - } - - rsa.setFileName (rsa_host_key.absoluteFilePath ()); - } -#endif - if ( !rsa.open ( QIODevice::ReadOnly | QIODevice::Text ) ) - { -#if defined (Q_OS_LINUX) || defined (Q_OS_DARWIN) + 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 ()) { + if (!(startSshd ())) { return (QString::null); } rsa.setFileName (tmp_file_name + ".pub"); - rsa.open ( QIODevice::ReadOnly | QIODevice::Text ); + rsa.open (QIODevice::ReadOnly | QIODevice::Text); #else - printSshDError_noHostPubKey(); + printSshDError_noHostPubKey (); return QString::null; #endif } @@ -8263,21 +8231,8 @@ void ONMainWindow::slotRetExportDir ( bool result,QString output, file.close(); QDir authorized_keys_dir (homeDir); + authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.x2go/.ssh/"); - /* - * Do the user SSHD/global SSHD dance here and either use the - * private .x2go/.ssh or the global .ssh dir. - * - * Note: Windows is implicitly always using an user-mode SSH server. - */ -#ifndef Q_OS_WIN - if (userSshd) -#endif /* !defined (Q_OS_WIN) */ - { - authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.x2go/"); - } - - authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.ssh/"); QFile authorized_keys_file (authorized_keys_dir.absolutePath () + "/authorized_keys"); /* @@ -9546,30 +9501,12 @@ void ONMainWindow::startX2goMount() file.close(); QDir authorized_keys_dir (homeDir); + authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.x2go/.ssh/"); - /* - * Do the user SSHD/global SSHD dance here and either use the - * private .x2go/.ssh or the global .ssh dir. - * - * Note: Windows is implicitly always using an user-mode SSH server. - */ -#ifndef Q_OS_WIN - if (userSshd) -#endif /* !defined (Q_OS_WIN) */ - { - authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.x2go/"); - } - - authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.ssh/"); QFile authorized_keys_file (authorized_keys_dir.absolutePath () + "/authorized_keys"); -#ifndef Q_OS_WIN - if (userSshd) -#endif /* !defined (Q_OS_WIN) */ - { - x2goDebug << "Creating dir " << authorized_keys_dir.absolutePath (); - authorized_keys_dir.mkpath (authorized_keys_dir.absolutePath ()); - } + x2goDebug << "Potentially creating dir " << authorized_keys_dir.absolutePath (); + authorized_keys_dir.mkpath (authorized_keys_dir.absolutePath ()); x2goDebug << "Potentially creating file " << authorized_keys_file.fileName (); if (!authorized_keys_file.open (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { @@ -9646,7 +9583,11 @@ void ONMainWindow::startX2goMount() QString cuser; -#ifndef Q_WS_HILDON +#ifdef Q_WS_HILDON + cuser="user"; +#elif defined (Q_OS_WIN) + cuser=wapiGetUserName(); +#else for ( int i=0; i<env.size(); ++i ) { QStringList ls=env[i].split ( "=" ); @@ -9657,11 +9598,6 @@ void ONMainWindow::startX2goMount() break; } } -#else - cuser="user"; -#endif -#ifdef Q_OS_WIN - cuser=wapiGetUserName(); #endif QString cmd; QString dirs=dir->dirList; @@ -10339,7 +10275,7 @@ QString ONMainWindow::generateKey(ONMainWindow::key_types key_type, bool host_ke QString tmp_to_add (""); if (host_key) { - QString tmp_to_add = "/ssh_host_" + stringified_key_type + "_key"; + tmp_to_add = "/ssh_host_" + stringified_key_type + "_key"; } else { QTemporaryFile temp_file (base_dir + "/key"); @@ -10427,17 +10363,7 @@ bool ONMainWindow::startSshd() { return false; } -#ifdef Q_OS_LINUX clientSshPort = "7022"; -#else // defined (Q_OS_LINUX) -#ifdef Q_OS_DARWIN - // Should also automatically create keys if Remote Login is enabled - // under Sharing in System Preferences. - if (!isServerRunning (clientSshPort.toInt ())) { - clientSshPort = "7022"; - } -#endif // defined (Q_OS_DARWIN) -#endif // defined (Q_OS_LINUX) QString etcDir=homeDir+"/.x2go/etc"; int port=clientSshPort.toInt(); //clientSshPort have initvalue @@ -10448,7 +10374,8 @@ bool ONMainWindow::startSshd() std::string clientdir=wapiShortFileName ( appDir ).toStdString(); std::stringstream strm; std::string config="\""+cygwinPath(etcDir+"/sshd_config").toStdString()+"\""; - std::string key="\""+cygwinPath(etcDir+"/ssh_host_dsa_key").toStdString()+"\""; + /* FIXME: make this generic! */ + std::string key="\""+cygwinPath(etcDir+"/ssh_host_rsa_key").toStdString()+"\""; // generate a unique sshLog filepath, and create its directory if (debugging) @@ -10513,21 +10440,20 @@ bool ONMainWindow::startSshd() delete []desktop; winSshdStarted=true; #else // defined (Q_OS_WIN) - userSshd=true; - sshd=new QProcess ( this ); - QString binary = appDir + "/sshd"; -#ifdef Q_OS_DARWIN - binary = "/usr/sbin/sshd"; -#endif // defined (Q_OS_DARWIN) + QString binary ("/usr/sbin/sshd"); +#ifndef Q_OS_UNIX + binary = appDir + "/sshd"; +#endif /* !(defined (Q_OS_UNIX)) */ QStringList arguments; + /* FIXME: make key selection more generic! */ arguments<<"-f"<<etcDir +"/sshd_config"<< "-h" << - etcDir+"/ssh_host_dsa_key"<<"-D"<<"-p"<<clientSshPort; + etcDir+"/ssh_host_rsa_key"<<"-D"<<"-p"<<clientSshPort; sshd->start (binary, arguments); -#endif // defined (Q_OS_WIN) +#endif /* defined (Q_OS_WIN) */ // Allow sshd a grace time of 3 seconds to come up. QTime sleepTime = QTime::currentTime ().addSecs (3); @@ -11968,67 +11894,24 @@ void ONMainWindow::printSshDError_startupFailure() return; QString error_message; -#ifdef Q_OS_WIN error_message = tr ("SSH daemon could not be started.\n\n"); -#else // defined (Q_OS_WIN) - if (userSshd) { - error_message = tr ("SSH daemon could not be started.\n\n"); - } - else { - error_message = tr ("SSH daemon is not running.\n\n"); - } -#endif // defined (Q_OS_WIN) QString detailed_error_message = tr ("You have enabled Remote Printing or File Sharing.\n" "These features require a running and functioning SSH server on your computer.\n" - "<b>Printing and File Sharing will be disabled for this session.</b>\n\n" - - "Please also check the <b>Clientside SSH port</b> in the general settings.\n\n"); + "<b>Printing and File Sharing will be disabled for this session.</b>\n\n"); #ifdef Q_OS_WIN detailed_error_message += tr ("Normally, this should not happen as X2Go Client for Windows " "ships its own internal SSH server.\n\n" - "If you see this message, please report a bug on:\n" - "<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">" + "If you see this message, please report a bug on:\n"); +#else /* defined (Q_OS_WIN) */ + detailed_error_message += tr ("The SSH server failed to start.\n\n" + + "Please report a bug on:\n"); +#endif /* defined (Q_OS_WIN) */ + detailed_error_message += tr ("<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">" "https://wiki.x2go.org/doku.php/wiki:bugs" "</a></center>\n"); -#else // defined (Q_OS_WIN) - if (userSshd) { - detailed_error_message += tr ("The SSH server failed to start.\n\n"); - detailed_error_message += tr ("X2Go Client did not detect a globally running SSH server " - "on your machine and was unable to start its own.\n\n" - - "Please report a bug on:\n" - "<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">" - "https://wiki.x2go.org/doku.php/wiki:bugs" - "</a></center>\n"); - } - else { - detailed_error_message += tr ("The SSH server is currently not started.\n\n"); -#ifdef Q_OS_DARWIN - detailed_error_message += tr ("On OS X, please follow the following steps to enable " - "SSH service:" - "<ul>" - "<li>Open <b>System Preferences</b> (Applications -> System Preferences)</li>" - "<li>Go to <b>Sharing</b></li>" - "<li>Tick the checkbox besides <b>Remote Login</b></li>" - "<li>Check that <b>Allow access for:</b> is set to either:" - "<ul>" - "<li>All users: <b>no further steps necessary</b></li>" - "<li>Only these users <b>and your user name is included in the list</b></li>" - "</ul>" - "<li>Optionally, add your user name to the allowed list " - "via the <b>Plus Button</b></li>" - "</ul>" - "<b>Warning: enabling SSH access will allow any user on the network to connect " - "to your machine. It is your responsibility to set a strong password for every " - "user that is allowed to log in via SSH.</b>\n\n"); -#else // defined (Q_OS_DARWIN) - detailed_error_message += tr ("Please ask your system administrator to provide the SSH " - "service on your computer.\n\n"); -#endif // defined (Q_OS_DARWIN) - } -#endif // defined (Q_OS_WIN) detailed_error_message += tr ("Disabling Remote Printing or File Sharing support " "in the session settings will get rid of this message."); @@ -12046,50 +11929,21 @@ void ONMainWindow::printSshDError_noHostPubKey() QString detailed_error_message = tr ("You have enabled Remote Printing or File Sharing.\n" "These features require a running and functioning SSH server on your computer.\n" - "<b>Printing and File Sharing will be disabled for this session.</b>\n\n" - - "The SSH server is currently not configured correctly.\n\n" - - "Please ensure that the server's public key exists.\n\n"); + "<b>Printing and File Sharing will be disabled for this session.</b>\n\n"); #ifdef Q_OS_WIN detailed_error_message += tr ("Normally, this should not happen as X2Go Client for Windows " "ships its own internal SSH server and automatically " "generates the required keys.\n\n" - "If you see this message, please report a bug on:\n" - "<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">" + "If you see this message, please report a bug on:\n"); +#else /* defined (Q_OS_WIN) */ + detailed_error_message += tr ("X2Go Client was unable to create SSH host keys.\n\n" + + "Please report a bug on:\n"); +#endif /* defined (Q_OS_WIN) */ + detailed_error_message += tr ("<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">" "https://wiki.x2go.org/doku.php/wiki:bugs" "</a></center>\n"); -#else // defined (Q_OS_WIN) - if (userSshd) { - detailed_error_message += tr ("X2Go Client was unable to create SSH host keys.\n\n" - - "Please report a bug on:\n" - "<center><a href=\"https://wiki.x2go.org/doku.php/wiki:bugs\">" - "https://wiki.x2go.org/doku.php/wiki:bugs" - "</a></center>\n"); - } - else { -#ifdef Q_OS_DARWIN - detailed_error_message += tr ("On OS X, please follow these steps to generate the " - "required keys:" - - "<ul>" - "<li>Open a <b>Terminal Window</b> (Applications -> Utilities -> Terminal)</li>" - "<li>Run this command: <b>ssh -p " + clientSshPort.toLatin1 () - + " localhost</b></li>" - "<li>You do not need to login. Just quit the Terminal application " - "via Cmd + Q</li>" - "</ul>"); -#else // defined (Q_OS_DARWIN) - detailed_error_message += tr ("Please ask your system administrator to generate the required host keys.\n\n" - - "If you are administrating this system yourself, please run:\n" - - "<center><b>sudo ssh-keygen -A</b></center>\n\n"); -#endif // defined (Q_OS_DARWIN) - } -#endif // defined (Q_OS_WIN) detailed_error_message += tr ("Disabling Remote Printing or File Sharing support " "in the session settings will get rid of this message."); diff --git a/src/onmainwindow.h b/src/onmainwindow.h index c86bceb..d5f1659 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -837,7 +837,6 @@ private: QProcess *nxproxy; #ifndef Q_OS_WIN QProcess *sshd; - bool userSshd; #else QProcess *xorg; PROCESS_INFORMATION sshd; -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git