ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #09946
[Merge] lp:~renatofilho/ubuntu-terminal-app/ssh-mode into lp:ubuntu-terminal-app
Renato Araujo Oliveira Filho has proposed merging lp:~renatofilho/ubuntu-terminal-app/ssh-mode into lp:ubuntu-terminal-app.
Commit message:
Start the app in ssh mode when using --ssh as arg.
This option is used by snappy to get access to the host file system. Without that the user is trapped on snappy enviroment and can not execute commands on host machine.
Requested reviews:
Ubuntu Terminal Developers (ubuntu-terminal-dev)
For more details, see:
https://code.launchpad.net/~renatofilho/ubuntu-terminal-app/ssh-mode/+merge/309288
--
Your team Ubuntu Terminal Developers is requested to review the proposed merge of lp:~renatofilho/ubuntu-terminal-app/ssh-mode into lp:ubuntu-terminal-app.
=== modified file 'src/app/main.cpp'
--- src/app/main.cpp 2016-03-15 14:18:34 +0000
+++ src/app/main.cpp 2016-10-25 17:54:02 +0000
@@ -26,16 +26,19 @@
#include <QtQml/QtQml>
#include <QLibrary>
#include <QDir>
+#include <QProcess>
#include "fileio.h"
#include <QDebug>
+
QString getNamedArgument(QStringList args, QString name, QString defaultName)
{
int index = args.indexOf(name);
return (index != -1) ? args[index + 1] : QString(defaultName);
}
+
QStringList getProfileFromDir(const QString &path) {
QDir layoutDir(path);
layoutDir.setNameFilters(QStringList("*.json"));
@@ -49,6 +52,15 @@
return result;
}
+bool sshdRunning() {
+ QProcess process;
+ QString pgm("pgrep");
+ QStringList args = QStringList() << "sshd";
+ process.start(pgm, args);
+ process.waitForReadyRead();
+ return !process.readAllStandardOutput().isEmpty();
+}
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@@ -90,12 +102,14 @@
qDebug() << " -h|--help Print this help.";
qDebug() << " -I <path> Give a path for an additional QML import directory. May be used multiple times.";
qDebug() << " -q <qmlfile> Give an alternative location for the main qml file.";
+ qDebug() << " --ssh Run a ssh session on local host instead of default bash.";
qDebug() << " --workdir <dir> Change working directory to 'dir'";
return 0;
}
//Dynamic folder home
- view.engine()->rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
+ view.engine()->rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
+
// Desktop doesn't have yet Unity8 and so no unity greeter either. Consequently it doesn't
// also have any "PIN code" or "Password" extra authentication. Don't require any extra
@@ -160,6 +174,20 @@
view.engine()->rootContext()->setContextProperty("tablet", QVariant(true));
}
+ if (args.contains("--ssh")) {
+ bool sshIsAvailable = sshdRunning();
+ view.engine()->rootContext()->setContextProperty("sshRequired", QVariant(true));
+ view.engine()->rootContext()->setContextProperty("sshIsAvailable", sshIsAvailable);
+ if (sshIsAvailable) {
+ view.engine()->rootContext()->setContextProperty("noAuthentication", QVariant(false));
+ view.engine()->rootContext()->setContextProperty("sshUser", qgetenv("USER"));
+ }
+ } else {
+ view.engine()->rootContext()->setContextProperty("sshRequired", QVariant(false));
+ view.engine()->rootContext()->setContextProperty("sshIsAvailable", QVariant(false));
+ view.engine()->rootContext()->setContextProperty("sshUser", "");
+ }
+
view.engine()->setImportPathList(importPathList);
QStringList keyboardLayouts;
=== modified file 'src/app/qml/AuthenticationService.qml'
--- src/app/qml/AuthenticationService.qml 2016-03-03 22:50:20 +0000
+++ src/app/qml/AuthenticationService.qml 2016-10-25 17:54:02 +0000
@@ -29,11 +29,11 @@
property var __authDialog
readonly property bool isDialogVisible: __authDialog != null
- signal granted()
+ signal granted(string password)
signal denied()
Component.onCompleted: {
- if ( systemAuthentication.requireAuthentication() && !noAuthentication) {
+ if ( (sshIsAvailable && sshRequired) || (systemAuthentication.requireAuthentication() && !noAuthentication)) {
displayLoginDialog();
}
}
@@ -50,7 +50,7 @@
var verify_password = function( password ) {
if ( systemAuthentication.validatePasswordToken( password ) ) {
- granted();
+ granted(password);
PopupUtils.close( authentication_dialog );
}
else {
=== added file 'src/app/qml/ConfirmationDialog.qml'
--- src/app/qml/ConfirmationDialog.qml 1970-01-01 00:00:00 +0000
+++ src/app/qml/ConfirmationDialog.qml 2016-10-25 17:54:02 +0000
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Renato Araujo Oliveira Filho <renatofilho@xxxxxxxxxxxxx>
+ */
+import QtQuick 2.4
+import Ubuntu.Components 1.3
+import Ubuntu.Components.Popups 1.3
+
+Dialog {
+ id: root
+
+ signal dialogCanceled
+ signal dialogAccepted
+
+ title: "oi"
+ text: "teste"
+ width: units.gu(80)
+ height: units.gu(80)
+
+ Button {
+ id: okButton
+ objectName: "continueButton"
+
+ text: i18n.tr("Continue")
+ color: UbuntuColors.green
+
+ onClicked: dialogAccepted()
+ }
+
+ Button {
+ id: cancelButton
+ objectName: "cancelButton"
+
+ text: i18n.tr("Cancel")
+ color: UbuntuColors.red
+
+ onClicked: dialogCanceled();
+ }
+}
=== modified file 'src/app/qml/TerminalComponent.qml'
--- src/app/qml/TerminalComponent.qml 2016-09-19 14:15:11 +0000
+++ src/app/qml/TerminalComponent.qml 2016-10-25 17:54:02 +0000
@@ -36,7 +36,11 @@
session: QMLTermSession {
id: terminalSession
initialWorkingDirectory: workdir
-
+ shellProgram: (mview.sshMode ? "sshpass" : "bash")
+ shellProgramArgs: (mview.sshMode ?
+ ["-p", mview.userPassword, "ssh", "-o", "UserKnownHostsFile=/dev/null",
+ "-o", "StrictHostKeyChecking=no", "%1@localhost".arg(sshUser)]
+ : [])
onFinished: tabsModel.removeTabWithSession(terminalSession);
}
=== modified file 'src/app/qml/ubuntu-terminal-app.qml'
--- src/app/qml/ubuntu-terminal-app.qml 2016-09-19 00:05:02 +0000
+++ src/app/qml/ubuntu-terminal-app.qml 2016-10-25 17:54:02 +0000
@@ -18,6 +18,7 @@
import QtQuick 2.4
import QtGraphicalEffects 1.0
import Ubuntu.Components 1.3
+import Ubuntu.Components.Popups 1.2
import "KeyboardRows"
import QMLTermWidget 1.0
@@ -28,6 +29,10 @@
MainView {
// objectName for functional testing purposes (autopilot-qt5)
id: mview
+
+ property string userPassword: ""
+ readonly property bool sshMode: sshIsAvailable && sshRequired && (userPassword != "")
+
objectName: "terminal"
applicationName: "com.ubuntu.terminal"
automaticOrientation: true
@@ -35,6 +40,13 @@
AuthenticationService {
id: authService
onDenied: Qt.quit();
+ onGranted: {
+ if (sshUser != "") {
+ userPassword = password
+ tabsModel.addTab()
+ tabsModel.removeTab(0)
+ }
+ }
}
TerminalSettings {
@@ -154,6 +166,20 @@
// Hardcoded value from TerminalDisplay.h
width = 80 * terminalPage.terminal.fontMetrics.width + 2
height = 24 * terminalPage.terminal.fontMetrics.height + 2
+
+ if (sshRequired && !sshIsAvailable) {
+ console.debug("Ask for confirmation")
+ var proceed_dialog =
+ PopupUtils.open( Qt.resolvedUrl( "ConfirmationDialog.qml" ),
+ terminalPage,
+ {'title': i18n.tr("No SSH server running."),
+ 'text': i18n.tr("SSH server not found. Do you want to proceed in confined mode?")});
+
+ proceed_dialog.dialogCanceled.connect( Qt.quit );
+ proceed_dialog.dialogAccepted.connect( function() {
+ PopupUtils.close(proceed_dialog)
+ })
+ }
}
InputDeviceManager {
@@ -184,4 +210,6 @@
property: "keyboardAttached"
value: keyboardsModel.count > 0
}
+
+
}
=== modified file 'src/plugin/qmltermwidget/lib/Session.cpp'
--- src/plugin/qmltermwidget/lib/Session.cpp 2016-09-19 14:13:51 +0000
+++ src/plugin/qmltermwidget/lib/Session.cpp 2016-10-25 17:54:02 +0000
@@ -263,7 +263,7 @@
qDebug() << "Session::run() - no command line arguments specified.";
}
else {
- qDebug() << "Session::run() - arguments:" << _arguments;
+ qDebug() << "Session::run() - arguments:" << _arguments.size();
}
// Upon a KPty error, there is no description on what that error was...
References