Merge lp:~larryprice/acolyterm/pkexec into lp:acolyterm

Proposed by Larry Price
Status: Merged
Approved by: Larry Price
Approved revision: 215
Merged at revision: 212
Proposed branch: lp:~larryprice/acolyterm/pkexec
Merge into: lp:acolyterm
Diff against target: 824 lines (+25/-589)
19 files modified
README.md (+0/-6)
debian/control (+0/-12)
debian/qtdeclarative5-pamauthentication0.1.install (+0/-1)
src/app/main.cpp (+18/-28)
src/app/qml/AuthenticationDialog.qml (+0/-78)
src/app/qml/AuthenticationService.qml (+0/-77)
src/app/qml/TerminalComponent.qml (+3/-4)
src/app/qml/TerminalPage.qml (+0/-2)
src/app/qml/acolyterm.qml (+1/-6)
src/plugin/CMakeLists.txt (+0/-1)
src/plugin/pamauthentication/CMakeLists.txt (+0/-37)
src/plugin/pamauthentication/pamauthentication.cpp (+0/-183)
src/plugin/pamauthentication/pamauthentication.h (+0/-72)
src/plugin/pamauthentication/pamauthentication_plugin.cpp (+0/-34)
src/plugin/pamauthentication/pamauthentication_plugin.h (+0/-39)
src/plugin/pamauthentication/qmldir (+0/-2)
src/plugin/qmltermwidget/lib/Session.cpp (+1/-1)
src/plugin/qmltermwidget/src/ksession.cpp (+1/-1)
tests/autopilot/acolyterm/tests/__init__.py (+1/-5)
To merge this branch: bzr merge lp:~larryprice/acolyterm/pkexec
Reviewer Review Type Date Requested Status
Libertine CI Bot continuous-integration Approve
Larry Price Approve
Review via email: mp+298119@code.launchpad.net

Commit message

Use pkexec to run default terminal and remove dependency on pam.

Description of the change

Use pkexec to run default terminal and remove dependency on pam.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:215
https://jenkins.canonical.com/libertine/job/lp-acolyterm-ci/25/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/72
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=autopilot/47
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=autopilot/47
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=autopilot/47
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=autopilot/47
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/62/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/73
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/63
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/63
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/56
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/56/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/56
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/56/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/56
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/56/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/56
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/56/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-acolyterm-ci/25/rebuild

review: Approve (continuous-integration)
Revision history for this message
Larry Price (larryprice) wrote :

pam removed successfully

review: Approve
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.canonical.com/libertine/job/lp-acolyterm-autoland/3/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/73
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=autopilot/48
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=autopilot/48
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=autopilot/48
    FAILURE: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=autopilot/48/console
    None: https://jenkins.canonical.com/libertine/job/lp-generic-land-mp/7/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/74
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/64
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/64
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/57
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/57/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/57
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/57/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/57
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/57/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/57
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/57/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
Libertine CI Bot (libertine-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2016-06-17 20:12:55 +0000
3+++ README.md 2016-06-22 13:29:28 +0000
4@@ -11,10 +11,6 @@
5
6 ### For the desktop
7
8-Install the following build dependencies:
9-
10- sudo apt-get install libpam0g-dev
11-
12 Then open the CMakeLists.txt file in Qt Creator, and ensure that the kit
13 selected on the left sidebar (just above the green "Run" button) is "Desktop"
14
15@@ -30,8 +26,6 @@
16 password
17 4. Once created, you'll need to add the build dependencies for the app:
18 - Click on the Maintain button on your chroot
19- - On the terminal prompt that is started, type
20- apt-get install libpam0g-dev:armhf
21 - Close the terminal when the installation finishes
22 5. Now you can either do a clean checkout and wait to be prompted by Qt Creator
23 to add the armhf kit, or alternatively:
24
25=== modified file 'debian/control'
26--- debian/control 2016-06-21 17:47:38 +0000
27+++ debian/control 2016-06-22 13:29:28 +0000
28@@ -7,7 +7,6 @@
29 python3-all,
30 gettext,
31 intltool,
32- libpam0g-dev,
33 qt5-default,
34 qtbase5-dev,
35 qtdeclarative5-dev,
36@@ -22,7 +21,6 @@
37 Depends: ${misc:Depends},
38 ${shlibs:Depends},
39 qtdeclarative5-qmltermwidget1.0,
40- qtdeclarative5-pamauthentication0.1,
41 qtdeclarative5-qtquick2-plugin,
42 qtdeclarative5-ubuntu-ui-toolkit-plugin,
43 qml-module-qtsysteminfo (>= 5.0~),
44@@ -39,16 +37,6 @@
45 This package contains the QMLTermWidget terminal emulator plugin
46 for Qt Qml.
47
48-Package: qtdeclarative5-pamauthentication0.1
49-Architecture: any
50-Multi-Arch: same
51-Depends: ${misc:Depends},
52- ${shlibs:Depends},
53- ${misc:Pre-Depends},
54-Description: PAM authentication QML plugin
55- This package contains a plugin that enables QML apps to do
56- password authentication via the PAM API.
57-
58 Package: acolyterm-autopilot
59 Architecture: all
60 Depends: ${misc:Depends},
61
62=== removed file 'debian/qtdeclarative5-pamauthentication0.1.install'
63--- debian/qtdeclarative5-pamauthentication0.1.install 2016-06-21 18:08:54 +0000
64+++ debian/qtdeclarative5-pamauthentication0.1.install 1970-01-01 00:00:00 +0000
65@@ -1,1 +0,0 @@
66-usr/lib/*/qt5/qml/com/ubuntu/PamAuthentication/
67
68=== modified file 'src/app/main.cpp'
69--- src/app/main.cpp 2016-06-17 14:47:16 +0000
70+++ src/app/main.cpp 2016-06-22 13:29:28 +0000
71@@ -85,7 +85,6 @@
72 QStringList args = a.arguments();
73 if (args.contains("-h") || args.contains("--help")) {
74 qDebug() << "usage: " + args.at(0) + " [--workdir <dir>] [-h|--help] [-I <path>] [-c <command> [-- <args>]]";
75- qDebug() << " --forceAuth Force authentication on or off.";
76 qDebug() << " -h|--help Print this help.";
77 qDebug() << " -I <path> Give a path for an additional QML import directory. May be used multiple times.";
78 qDebug() << " -q <qmlfile> Give an alternative location for the main qml file.";
79@@ -94,34 +93,30 @@
80 return 0;
81 }
82
83+ QStringList commandArguments;
84 auto command = getNamedArgument(args, "-c", "");
85+ if (!command.isEmpty())
86+ {
87+ auto cmdArgsIdx = args.indexOf("--");
88+ if (cmdArgsIdx != -1)
89+ {
90+ commandArguments = args.mid(cmdArgsIdx+1);
91+ }
92+ view.engine()->rootContext()->setContextProperty("disableTabs", QVariant(true));
93+ }
94+ else
95+ {
96+ command = "pkexec";
97+ commandArguments = QStringList({"--user", "$USER", "/bin/bash"});
98+ view.engine()->rootContext()->setContextProperty("disableTabs", QVariant(false));
99+ }
100+
101 view.engine()->rootContext()->setContextProperty("command", command);
102- view.engine()->rootContext()->setContextProperty("disableTabs", QVariant(!command.isEmpty()));
103-
104- QStringList commandArguments;
105- auto cmdArgsIdx = args.indexOf("--");
106- if (cmdArgsIdx != -1)
107- {
108- commandArguments = args.mid(cmdArgsIdx+1);
109- }
110 view.engine()->rootContext()->setContextProperty("commandArguments", commandArguments);
111
112 //Dynamic folder home
113 view.engine()->rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
114
115- // Desktop doesn't have Unity8 and so no unity greeter either. Consequently it doesn't
116- // also have any "PIN code" or "Password" extra authentication. Don't require any extra
117- // authentication there by default
118- if (qgetenv("QT_QPA_PLATFORM") != "ubuntumirclient")
119- {
120- qDebug() << Q_FUNC_INFO << "Running on non-MIR desktop, not requiring authentication by default";
121- view.engine()->rootContext()->setContextProperty("noAuthentication", QVariant(true));
122- }
123- else
124- {
125- view.engine()->rootContext()->setContextProperty("noAuthentication", QVariant(false));
126- }
127-
128 QString qmlfile;
129 for (auto i = 0; i < args.count(); ++i)
130 {
131@@ -138,11 +133,6 @@
132 {
133 qmlfile = args.at(i+1);
134 }
135- else if (args.at(i) == "--forceAuth" && args.count() > i + 1)
136- {
137- qDebug() << Q_FUNC_INFO << "Forcing authentication on";
138- view.engine()->rootContext()->setContextProperty("noAuthentication", QVariant(false));
139- }
140 }
141
142 view.engine()->setImportPathList(importPathList);
143@@ -194,7 +184,7 @@
144 QStringList configLocations = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
145 for (auto const& path: configLocations)
146 {
147- QString fullPath = path + "/com.ubuntu.terminal/Layouts/";
148+ QString fullPath = path + "/com.ubuntu.acolyterm/Layouts/";
149 qDebug() << "Retrieving keyboard profiles from folder: " << fullPath;
150 keyboardLayouts << getProfileFromDir(fullPath);
151 }
152
153=== removed file 'src/app/qml/AuthenticationDialog.qml'
154--- src/app/qml/AuthenticationDialog.qml 2016-02-13 04:00:02 +0000
155+++ src/app/qml/AuthenticationDialog.qml 1970-01-01 00:00:00 +0000
156@@ -1,78 +0,0 @@
157-/*
158- * Copyright (C) 2014 Canonical Ltd
159- *
160- * This program is free software: you can redistribute it and/or modify
161- * it under the terms of the GNU General Public License version 3 as
162- * published by the Free Software Foundation.
163- *
164- * This program is distributed in the hope that it will be useful,
165- * but WITHOUT ANY WARRANTY; without even the implied warranty of
166- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
167- * GNU General Public License for more details.
168- *
169- * You should have received a copy of the GNU General Public License
170- * along with this program. If not, see <http://www.gnu.org/licenses/>.
171- *
172- * Authored by: Arto Jalkanen <ajalkane@gmail.com>
173- */
174-import QtQuick 2.4
175-import Ubuntu.Components 1.3
176-import Ubuntu.Components.Popups 1.3
177-
178-Dialog {
179- id: root
180-
181- title: i18n.tr("Authentication required")
182-
183- text: i18n.tr("Enter passcode or passphrase:")
184-
185- signal passwordEntered(string password)
186- signal dialogCanceled
187-
188- // Due to several different things forcing focus
189- // on creation, we simply create this timer to
190- // work around that (see bugs #1488481 and #1499994)
191- Timer {
192- interval: 1
193- running: true
194- onTriggered: passwordField.forceActiveFocus()
195- }
196-
197- Component.onCompleted: {
198- passwordField.forceActiveFocus();
199- }
200-
201- TextField {
202- id: passwordField
203- objectName: "inputField"
204- placeholderText: i18n.tr("passcode or passphrase")
205- echoMode: TextInput.Password
206-
207- onAccepted: okButton.clicked(text)
208- }
209-
210- Button {
211- id: okButton
212- objectName: "okButton"
213-
214- text: i18n.tr("OK")
215- color: UbuntuColors.green
216-
217- onClicked: {
218- passwordEntered(passwordField.text)
219- passwordField.text = "";
220- }
221- }
222-
223- Button {
224- id: cancelButton
225- objectName: "cancelButton"
226- text: i18n.tr("Cancel")
227-
228- color: UbuntuColors.red
229-
230- onClicked: {
231- dialogCanceled();
232- }
233- }
234-}
235
236=== removed file 'src/app/qml/AuthenticationService.qml'
237--- src/app/qml/AuthenticationService.qml 2016-03-03 22:50:20 +0000
238+++ src/app/qml/AuthenticationService.qml 1970-01-01 00:00:00 +0000
239@@ -1,77 +0,0 @@
240-/*
241- * Copyright (C) 2014 Canonical Ltd
242- *
243- * This program is free software: you can redistribute it and/or modify
244- * it under the terms of the GNU General Public License version 3 as
245- * published by the Free Software Foundation.
246- *
247- * This program is distributed in the hope that it will be useful,
248- * but WITHOUT ANY WARRANTY; without even the implied warranty of
249- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
250- * GNU General Public License for more details.
251- *
252- * You should have received a copy of the GNU General Public License
253- * along with this program. If not, see <http://www.gnu.org/licenses/>.
254- */
255-import QtQuick 2.4
256-import Ubuntu.Components 1.3
257-import Ubuntu.Components.Popups 1.3
258-import com.ubuntu.PamAuthentication 0.1
259-
260-/**
261- A simple service for authentication.
262- Displays login dialog and fires signals
263- on access approval or denial.
264- */
265-Item {
266- id: authenticationService
267-
268- property var __authDialog
269- readonly property bool isDialogVisible: __authDialog != null
270-
271- signal granted()
272- signal denied()
273-
274- Component.onCompleted: {
275- if ( systemAuthentication.requireAuthentication() && !noAuthentication) {
276- displayLoginDialog();
277- }
278- }
279-
280- /**
281- Displays the login dialog
282- and fires success or failure depending
283- on user input.
284- */
285- function displayLoginDialog() {
286- var authentication_dialog =
287- PopupUtils.open( Qt.resolvedUrl( "AuthenticationDialog.qml" ),
288- authenticationService );
289-
290- var verify_password = function( password ) {
291- if ( systemAuthentication.validatePasswordToken( password ) ) {
292- granted();
293- PopupUtils.close( authentication_dialog );
294- }
295- else {
296- var dialog_options = {
297- title : i18n.tr( "Authentication failed" )
298- };
299-
300- PopupUtils.open( Qt.resolvedUrl( "NotifyDialog.qml" ),
301- authenticationService,
302- dialog_options );
303- }
304- };
305-
306- authentication_dialog.passwordEntered.connect( verify_password );
307- authentication_dialog.dialogCanceled.connect( denied );
308-
309- __authDialog = authentication_dialog
310- }
311-
312- PamAuthentication {
313- id: systemAuthentication
314- serviceName: "terminal"
315- }
316-}
317
318=== modified file 'src/app/qml/TerminalComponent.qml'
319--- src/app/qml/TerminalComponent.qml 2016-06-17 14:47:16 +0000
320+++ src/app/qml/TerminalComponent.qml 2016-06-22 13:29:28 +0000
321@@ -62,10 +62,9 @@
322 }
323
324 Component.onCompleted: {
325- if (command !== "") {
326- terminalSession.setShellProgram(command);
327- terminalSession.setArgs(commandArguments);
328- }
329+ terminalSession.setShellProgram(command);
330+ terminalSession.setArgs(commandArguments);
331+
332 terminalSession.startShellProgram();
333 forceActiveFocus();
334 }
335
336=== modified file 'src/app/qml/TerminalPage.qml'
337--- src/app/qml/TerminalPage.qml 2016-06-17 14:47:16 +0000
338+++ src/app/qml/TerminalPage.qml 2016-06-22 13:29:28 +0000
339@@ -53,8 +53,6 @@
340 bottom: keyboardBarLoader.top
341 }
342
343- // Hide terminal data when the access is still not granted
344- layer.enabled: authService.isDialogVisible
345 layer.effect: FastBlur {
346 radius: units.gu(6)
347 }
348
349=== modified file 'src/app/qml/acolyterm.qml'
350--- src/app/qml/acolyterm.qml 2016-06-17 14:47:16 +0000
351+++ src/app/qml/acolyterm.qml 2016-06-22 13:29:28 +0000
352@@ -32,14 +32,9 @@
353 // objectName for functional testing purposes (autopilot-qt5)
354 id: mview
355 objectName: "terminal"
356- applicationName: "com.ubuntu.terminal"
357+ applicationName: "com.ubuntu.acolyterm"
358 automaticOrientation: true
359
360- AuthenticationService {
361- id: authService
362- onDenied: Qt.quit();
363- }
364-
365 TerminalSettings {
366 id: settings
367 }
368
369=== modified file 'src/plugin/CMakeLists.txt'
370--- src/plugin/CMakeLists.txt 2014-10-25 04:42:31 +0000
371+++ src/plugin/CMakeLists.txt 2016-06-22 13:29:28 +0000
372@@ -5,4 +5,3 @@
373 find_package(Qt5Widgets)
374
375 add_subdirectory(qmltermwidget)
376-add_subdirectory(pamauthentication)
377
378=== removed directory 'src/plugin/pamauthentication'
379=== removed file 'src/plugin/pamauthentication/CMakeLists.txt'
380--- src/plugin/pamauthentication/CMakeLists.txt 2014-10-25 04:42:31 +0000
381+++ src/plugin/pamauthentication/CMakeLists.txt 1970-01-01 00:00:00 +0000
382@@ -1,37 +0,0 @@
383-include_directories(
384- ${CMAKE_CURRENT_SOURCE_DIR}
385-)
386-
387-set(PLUGIN_DIR com/ubuntu/PamAuthentication)
388-
389-set(pamauthentication_SRCS
390- pamauthentication.cpp
391- pamauthentication.h
392- pamauthentication_plugin.cpp
393- pamauthentication_plugin.h
394-)
395-
396-add_library(PamAuthentication MODULE
397- ${pamauthentication_SRCS}
398-)
399-
400-target_link_libraries(PamAuthentication pam)
401-
402-qt5_use_modules(PamAuthentication Gui Qml Quick Widgets DBus)
403-
404-# Copy the plugin, the qmldir file and other assets to the build dir for running in QtCreator
405-if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
406- add_custom_command(TARGET PamAuthentication POST_BUILD
407- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR}
408- COMMENT "Creating plugin directory layout in the build directory"
409- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR}
410- COMMENT "Copying the qmldir file to the build directory"
411- COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:PamAuthentication> ${CMAKE_CURRENT_BINARY_DIR}/../${PLUGIN_DIR}
412- COMMENT "Copying the plugin binary to the build directory"
413- )
414-endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
415-
416-# Install plugin file
417-install(TARGETS PamAuthentication DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
418-install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
419-
420
421=== removed file 'src/plugin/pamauthentication/pamauthentication.cpp'
422--- src/plugin/pamauthentication/pamauthentication.cpp 2014-10-25 04:42:31 +0000
423+++ src/plugin/pamauthentication/pamauthentication.cpp 1970-01-01 00:00:00 +0000
424@@ -1,183 +0,0 @@
425-/*
426- * Copyright (C) 2014 Canonical Ltd
427- *
428- * This program is free software: you can redistribute it and/or modify
429- * it under the terms of the GNU General Public License version 3 as
430- * published by the Free Software Foundation.
431- *
432- * This program is distributed in the hope that it will be useful,
433- * but WITHOUT ANY WARRANTY; without even the implied warranty of
434- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
435- * GNU General Public License for more details.
436- *
437- * You should have received a copy of the GNU General Public License
438- * along with this program. If not, see <http://www.gnu.org/licenses/>.
439- *
440- * Author : Arto Jalkanen <ajalkane@gmail.com>
441- */
442-
443-#include "pamauthentication.h"
444-
445-#include <QDebug>
446-#include <QtDBus/QtDBus>
447-
448-#include <security/pam_appl.h>
449-
450-#define UNITYGREETER_SERVICE "com.canonical.UnityGreeter"
451-#define UNITYGREETER_PATH "/list"
452-#define UNITYGREETER_INTERFACE "com.canonical.UnityGreeter.List"
453-#define UNITYGREETER_PROPERTY_ENTRY_IS_LOCKED "EntryIsLocked"
454-
455-
456-PamAuthentication::PamAuthentication(QObject *parent) :
457- QObject(parent)
458-{
459- m_userLogin = qgetenv("USER");
460-}
461-
462-PamAuthentication::~PamAuthentication() {
463-
464-}
465-
466-void
467-PamAuthentication::setServiceName(const QString &serviceName) {
468- if (serviceName != m_serviceName) {
469- m_serviceName = serviceName;
470- emit serviceNameChanged();
471- }
472-}
473-
474-bool
475-PamAuthentication::requireAuthentication() {
476- // Desktop doesn't have yet Unity8 and so no unity greeter either. Consequently it doesn't
477- // also have any "PIN code" or "Password" extra authentication. Don't require any extra
478- // authentication there.
479- if (qgetenv("QT_QPA_PLATFORM") != "ubuntumirclient") {
480- qDebug() << Q_FUNC_INFO << "Running on non-MIR desktop, not requiring authentication";
481- return false;
482- }
483-
484- QDBusInterface dbus_iface(UNITYGREETER_SERVICE, UNITYGREETER_PATH, UNITYGREETER_INTERFACE);
485-
486- qDebug() << Q_FUNC_INFO << "Querying if authentication required";
487-
488- if (!dbus_iface.isValid()) {
489- qDebug() << Q_FUNC_INFO << "Not a valid dbus interface";
490- qDebug() << Q_FUNC_INFO << "Last error: " + dbus_iface.lastError().message();
491- // By default be cautious and require authentication
492- return true;
493- }
494- QVariant isLockedVariant = dbus_iface.property(UNITYGREETER_PROPERTY_ENTRY_IS_LOCKED);
495- if (isLockedVariant.isValid()) {
496- bool replyValue = isLockedVariant.toBool();
497- qDebug() << Q_FUNC_INFO << "Return value" << replyValue;
498- return replyValue;
499- } else {
500- qDebug() << Q_FUNC_INFO << "Failed getting value for EntryIsLocked property";
501- }
502- // By default be cautious and require authentication
503- return true;
504-}
505-
506-bool
507-PamAuthentication::validatePasswordToken(const QString &token) {
508- pam_handle *pamHandle = 0;
509- if (!initPam(&pamHandle)) {
510- qDebug() << Q_FUNC_INFO << "Pam init failed";
511- return false;
512- }
513-
514- m_passwordToken = token;
515-
516- int status = pam_authenticate(pamHandle, 0);
517- qDebug() << Q_FUNC_INFO << "Pam authenticate status" << status << pam_strerror(pamHandle, status);
518- if (status == PAM_SUCCESS) {
519- status = validateAccount(pamHandle);
520- }
521- pam_end(pamHandle, status);
522-
523- m_passwordToken.clear();
524-
525- return status == PAM_SUCCESS;
526-}
527-
528-int
529-PamAuthentication::validateAccount(pam_handle *pamHandle) {
530- // This makes sure account and password are still valid
531- int status = pam_acct_mgmt(pamHandle, 0);
532- qDebug() << Q_FUNC_INFO << "pam_acct_mgmt: " << status << pam_strerror(pamHandle, status);
533- // Placeholders for some common errors
534- // IMPROVE: it'd be good to let user know reason for failure
535- switch (status) {
536- case PAM_SUCCESS:
537- break;
538- case PAM_USER_UNKNOWN:
539- break;
540- case PAM_ACCT_EXPIRED:
541- break;
542- case PAM_NEW_AUTHTOK_REQD:
543- break;
544- }
545- return status;
546-}
547-
548-bool
549-PamAuthentication::initPam(pam_handle **pamHandle)
550-{
551- pam_conv conversation;
552- conversation.conv = ConversationFunction;
553- conversation.appdata_ptr = static_cast<void *>(this);
554-
555- return pam_start(m_serviceName.toLocal8Bit().data(), m_userLogin.toLocal8Bit().data(),
556- &conversation, pamHandle) == PAM_SUCCESS;
557-}
558-
559-int PamAuthentication::ConversationFunction(int num_msg,
560- const pam_message **msg,
561- pam_response **resp,
562- void* appdata_ptr)
563-{
564- if (num_msg <= 0) {
565- return PAM_CONV_ERR;
566- }
567-
568- *resp = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response)));
569-
570- PamAuthentication *self = static_cast<PamAuthentication*>(appdata_ptr);
571-
572- for (int count = 0; count < num_msg; ++count) {
573- switch (msg[count]->msg_style) {
574- case PAM_PROMPT_ECHO_ON:
575- {
576- qDebug() << Q_FUNC_INFO << "PAM_PROMPT_ECHO_ON received";
577- resp[count]->resp = strdup(self->m_passwordToken.toLocal8Bit().data());
578- resp[count]->resp_retcode = 0;
579- break;
580- }
581- case PAM_PROMPT_ECHO_OFF:
582- {
583- qDebug() << Q_FUNC_INFO << "PAM_PROMPT_ECHO_OFF received";
584- resp[count]->resp = strdup(self->m_passwordToken.toLocal8Bit().data());
585- resp[count]->resp_retcode = 0;
586- break;
587- }
588- case PAM_TEXT_INFO:
589- {
590- QString message(msg[count]->msg);
591- qDebug() << Q_FUNC_INFO << "PAM_TEXT_INFO received" << message;
592- break;
593- }
594- case PAM_AUTHTOK:
595- {
596- qDebug() << Q_FUNC_INFO << "PAM_AUTHTOK received";
597- break;
598- }
599- default:
600- {
601- qDebug() << Q_FUNC_INFO << "Other PAM msg received: " << msg[count]->msg_style;
602- }
603- }
604- }
605-
606- return PAM_SUCCESS;
607-}
608
609=== removed file 'src/plugin/pamauthentication/pamauthentication.h'
610--- src/plugin/pamauthentication/pamauthentication.h 2014-10-25 04:42:31 +0000
611+++ src/plugin/pamauthentication/pamauthentication.h 1970-01-01 00:00:00 +0000
612@@ -1,72 +0,0 @@
613-/*
614- * Copyright (C) 2014 Canonical Ltd
615- *
616- * This program is free software: you can redistribute it and/or modify
617- * it under the terms of the GNU General Public License version 3 as
618- * published by the Free Software Foundation.
619- *
620- * This program is distributed in the hope that it will be useful,
621- * but WITHOUT ANY WARRANTY; without even the implied warranty of
622- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
623- * GNU General Public License for more details.
624- *
625- * You should have received a copy of the GNU General Public License
626- * along with this program. If not, see <http://www.gnu.org/licenses/>.
627- *
628- * Author : Arto Jalkanen <ajalkane@gmail.com>
629- */
630-
631-#ifndef PAMAUTHENTICATION_H
632-#define PAMAUTHENTICATION_H
633-
634-#include <QObject>
635-#include <QAbstractListModel>
636-#include <QStandardPaths>
637-#include <QSettings>
638-
639-// Forward declarations
640-struct pam_handle;
641-struct pam_message;
642-struct pam_response;
643-
644-// TODO: documentation
645-class PamAuthentication : public QObject
646-{
647- Q_OBJECT
648-
649-public:
650- explicit PamAuthentication(QObject *parent = 0);
651- ~PamAuthentication();
652-
653- Q_INVOKABLE bool requireAuthentication();
654-
655- Q_INVOKABLE bool validatePasswordToken(const QString &token);
656-
657- Q_PROPERTY(QString serviceName READ serviceName WRITE setServiceName NOTIFY serviceNameChanged)
658- inline const QString &serviceName() const {
659- return m_serviceName;
660- }
661-
662- void setServiceName(const QString &serviceName);
663-signals:
664- void serviceNameChanged();
665-
666-public slots:
667-private:
668- static int ConversationFunction(int num_msg,
669- const pam_message** msg,
670- pam_response** resp,
671- void* appdata_ptr);
672-
673- bool initPam(pam_handle **pamHandle);
674- int validateAccount(pam_handle *pamHandle);
675-
676- QString m_passwordToken;
677- QString m_serviceName;
678- QString m_userLogin;
679-};
680-
681-#endif // PAMAUTHENTICATION_H
682-
683-
684-
685
686=== removed file 'src/plugin/pamauthentication/pamauthentication_plugin.cpp'
687--- src/plugin/pamauthentication/pamauthentication_plugin.cpp 2014-10-25 04:42:31 +0000
688+++ src/plugin/pamauthentication/pamauthentication_plugin.cpp 1970-01-01 00:00:00 +0000
689@@ -1,34 +0,0 @@
690-/*
691- * Copyright (C) 2014 Canonical Ltd
692- *
693- * This program is free software: you can redistribute it and/or modify
694- * it under the terms of the GNU General Public License version 3 as
695- * published by the Free Software Foundation.
696- *
697- * This program is distributed in the hope that it will be useful,
698- * but WITHOUT ANY WARRANTY; without even the implied warranty of
699- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
700- * GNU General Public License for more details.
701- *
702- * You should have received a copy of the GNU General Public License
703- * along with this program. If not, see <http://www.gnu.org/licenses/>.
704- *
705- * Author : Arto Jalkanen <ajalkane@gmail.com>
706- */
707-
708-#include <QtQml>
709-#include <QtQml/QQmlContext>
710-#include "pamauthentication_plugin.h"
711-#include "pamauthentication.h"
712-
713-void BackendPlugin::registerTypes(const char *uri)
714-{
715- Q_ASSERT(uri == QLatin1String("com.ubuntu.PamAuthentication"));
716-
717- qmlRegisterType<PamAuthentication>(uri, 0, 1, "PamAuthentication");
718-}
719-
720-void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
721-{
722- QQmlExtensionPlugin::initializeEngine(engine, uri);
723-}
724
725=== removed file 'src/plugin/pamauthentication/pamauthentication_plugin.h'
726--- src/plugin/pamauthentication/pamauthentication_plugin.h 2014-10-25 04:42:31 +0000
727+++ src/plugin/pamauthentication/pamauthentication_plugin.h 1970-01-01 00:00:00 +0000
728@@ -1,39 +0,0 @@
729-/*
730- * Copyright (C) 2014 Canonical Ltd
731- *
732- * This program is free software: you can redistribute it and/or modify
733- * it under the terms of the GNU General Public License version 3 as
734- * published by the Free Software Foundation.
735- *
736- * This program is distributed in the hope that it will be useful,
737- * but WITHOUT ANY WARRANTY; without even the implied warranty of
738- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
739- * GNU General Public License for more details.
740- *
741- * You should have received a copy of the GNU General Public License
742- * along with this program. If not, see <http://www.gnu.org/licenses/>.
743- *
744- * Author : Arto Jalkanen <ajalkane@gmail.com>
745- */
746-
747-#ifndef PAMAUTHENTICATION_PLUGIN_H
748-#define PAMAUTHENTICATION_PLUGIN_H
749-
750-#include <QtQml/QQmlEngine>
751-#include <QtQml/QQmlExtensionPlugin>
752-
753-class BackendPlugin : public QQmlExtensionPlugin
754-{
755- Q_OBJECT
756- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
757-
758-public:
759- void registerTypes(const char *uri);
760- void initializeEngine(QQmlEngine *engine, const char *uri);
761-};
762-#endif // PAMAUTHENTICATION_PLUGIN_H
763-
764-
765-
766-
767-
768
769=== removed file 'src/plugin/pamauthentication/qmldir'
770--- src/plugin/pamauthentication/qmldir 2014-10-25 04:42:31 +0000
771+++ src/plugin/pamauthentication/qmldir 1970-01-01 00:00:00 +0000
772@@ -1,2 +0,0 @@
773-module com.ubuntu.PamAuthentication
774-plugin PamAuthentication
775
776=== modified file 'src/plugin/qmltermwidget/lib/Session.cpp'
777--- src/plugin/qmltermwidget/lib/Session.cpp 2016-06-15 14:47:59 +0000
778+++ src/plugin/qmltermwidget/lib/Session.cpp 2016-06-22 13:29:28 +0000
779@@ -211,7 +211,7 @@
780 QObject::connect( widget ,SIGNAL(destroyed(QObject *)) , this ,
781 SLOT(viewDestroyed(QObject *)) );
782 //slot for close
783- QObject::connect(this, SIGNAL(finished()), widget, SLOT(close()));
784+ QObject::connect(this, &Session::finished, widget, &TerminalDisplay::deleteLater);
785
786 }
787
788
789=== modified file 'src/plugin/qmltermwidget/src/ksession.cpp'
790--- src/plugin/qmltermwidget/src/ksession.cpp 2016-06-15 14:47:59 +0000
791+++ src/plugin/qmltermwidget/src/ksession.cpp 2016-06-22 13:29:28 +0000
792@@ -236,7 +236,7 @@
793 m_session->sendText(text);
794 }
795
796-void KSession::sendKey(int rep, int key, int mod) const
797+void KSession::sendKey(int, int, int) const
798 {
799 //TODO implement or remove this function.
800 // Qt::KeyboardModifier kbm = Qt::KeyboardModifier(mod);
801
802=== modified file 'tests/autopilot/acolyterm/tests/__init__.py'
803--- tests/autopilot/acolyterm/tests/__init__.py 2016-06-21 17:48:43 +0000
804+++ tests/autopilot/acolyterm/tests/__init__.py 2016-06-22 13:29:28 +0000
805@@ -104,10 +104,6 @@
806
807 @autopilot_logging.log_action(logger.info)
808 def launch_test_click(self):
809- # We need to pass the "--forceAuth false" argument to the acolyterm app
810- # binary, but ubuntu-app-launch doesn't pass arguments to the exec line
811- # on the desktop file. So we make a test desktop file that has the
812- # "--forceAuth false" on the exec line.
813 desktop_file_path = self.write_sandbox_desktop_file()
814 desktop_file_name = os.path.basename(desktop_file_path)
815 application_name, _ = os.path.splitext(desktop_file_name)
816@@ -123,7 +119,7 @@
817 version, installed_path = self.get_installed_version_and_directory()
818 acolyterm_sandbox_exec = (
819 'aa-exec-click -p com.ubuntu.acolyterm_acolyterm_{}'
820- ' -- acolyterm --forceAuth false'.format(version))
821+ ' -- acolyterm'.format(version))
822 desktop_file_dict = {
823 'Type': 'Application',
824 'Name': 'acolyterm',

Subscribers

People subscribed via source and target branches

to all changes: