Merge lp:~mterry/unity8/unlock-via-dbus into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1208
Merged at revision: 1224
Proposed branch: lp:~mterry/unity8/unlock-via-dbus
Merge into: lp:unity8
Diff against target: 121 lines (+19/-16)
6 files modified
plugins/LightDM/DBusGreeter.cpp (+5/-0)
plugins/LightDM/DBusGreeter.h (+1/-0)
plugins/LightDM/Greeter.h (+1/-0)
qml/Shell.qml (+1/-1)
tests/qmltests/tst_Shell.qml (+3/-2)
tools/unlock-device (+8/-13)
To merge this branch: bzr merge lp:~mterry/unity8/unlock-via-dbus
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Albert Astals Cid (community) Approve
Martin Pitt Approve
Review via email: mp+232428@code.launchpad.net

Commit message

With recent password support, we want to be able to unlock the device even with a password set. And we need to be able to do this once the new adbd lands. So I've added a DBus command to hide the greeter. This should be secure because all apps are constrained and if you're on the local session bus unconstrained, you already have access to anything you want.

Description of the change

With recent password support, we want to be able to unlock the device even with a password set. And we need to be able to do this once the new adbd lands. So I've added a DBus command to hide the greeter. This should be secure because all apps are constrained and if you're on the local session bus unconstrained, you already have access to anything you want.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 - No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 - Yes

 * Did you make sure that your branch does not contain spurious tags?
 - Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 - NA

 * If you changed the UI, has there been a design review?
 - NA

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) :
Revision history for this message
Martin Pitt (pitti) wrote :

Awesome, thanks! I have one diff comment to be future proof.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

Updated to look at the adb user's id value for future proofing, thanks pitti!

lp:~mterry/unity8/unlock-via-dbus updated
1207. By Michael Terry

Handle future adb user changes

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Pitt (pitti) wrote :

Yay, thanks!

review: Approve
lp:~mterry/unity8/unlock-via-dbus updated
1208. By Michael Terry

Fix typo

Revision history for this message
Albert Astals Cid (aacid) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass? If not, please explain why.
Unrelated issues

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~mterry/unity8/unlock-via-dbus updated
1209. By Michael Terry

Force a delay of 20s to wait for unity8

Revision history for this message
Paul Larson (pwlars) wrote :

Doesn't seem to work:
I: Unlock failed, script output: 'Error connecting: Cannot autolaunch D-Bus with'ut X11 $DISPLAY

That was tested on mako, haven't tried krillin yet, but I'm not thinking it would do better there.

Revision history for this message
Michael Terry (mterry) wrote :

We tested this, it's because of an incompatibility with new adbd (pitti's suggested change was actually harmful! We need to go through sudo always to get the proper environment)

I'll propose another MP with that fix

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, you probably need "su -l" to read /etc/profile.d?

> We need to go through sudo always to get the proper environment)

Not always, that won't work if you are already the "phablet" user. So the "if" condition is right IMHO, you might just need su -l, or sudo to read profile.

Revision history for this message
Michael Terry (mterry) wrote :

It actually does work if you're already the phablet user! So that one line works for pre- and post-fix adbd.

Revision history for this message
Martin Pitt (pitti) wrote :

Confirmed, this works well even with adb running as phablet:

adb shell "sudo -u phablet -i gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked"

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/LightDM/DBusGreeter.cpp'
2--- plugins/LightDM/DBusGreeter.cpp 2014-06-27 22:08:19 +0000
3+++ plugins/LightDM/DBusGreeter.cpp 2014-08-28 20:00:25 +0000
4@@ -39,6 +39,11 @@
5 return Q_EMIT m_greeter->showGreeter();
6 }
7
8+void DBusGreeter::HideGreeter()
9+{
10+ return Q_EMIT m_greeter->hideGreeter();
11+}
12+
13 void DBusGreeter::isActiveChangedHandler()
14 {
15 notifyPropertyChanged("IsActive", isActive());
16
17=== modified file 'plugins/LightDM/DBusGreeter.h'
18--- plugins/LightDM/DBusGreeter.h 2014-06-27 22:08:19 +0000
19+++ plugins/LightDM/DBusGreeter.h 2014-08-28 20:00:25 +0000
20@@ -38,6 +38,7 @@
21
22 bool isActive() const;
23 Q_SCRIPTABLE void ShowGreeter(); // temporary, until we split the greeter again
24+ Q_SCRIPTABLE void HideGreeter(); // temporary, until we split the greeter again
25
26 Q_SIGNALS:
27 void isActiveChanged();
28
29=== modified file 'plugins/LightDM/Greeter.h'
30--- plugins/LightDM/Greeter.h 2014-08-15 20:23:54 +0000
31+++ plugins/LightDM/Greeter.h 2014-08-28 20:00:25 +0000
32@@ -62,6 +62,7 @@
33 void isAuthenticatedChanged();
34 void promptlessChanged();
35 void showGreeter();
36+ void hideGreeter();
37
38 // This signal is emitted by external agents like indicators, and the UI
39 // should switch to this user if possible.
40
41=== modified file 'qml/Shell.qml'
42--- qml/Shell.qml 2014-08-26 16:27:42 +0000
43+++ qml/Shell.qml 2014-08-28 20:00:25 +0000
44@@ -271,6 +271,7 @@
45 target: LightDM.Greeter
46
47 onShowGreeter: greeter.show()
48+ onHideGreeter: greeter.login()
49
50 onShowPrompt: {
51 if (greeter.narrowMode) {
52@@ -313,7 +314,6 @@
53 }
54
55 if (LightDM.Greeter.authenticated) {
56- lockscreen.hide();
57 greeter.login();
58 } else {
59 AccountsService.failedLogins++
60
61=== modified file 'tests/qmltests/tst_Shell.qml'
62--- tests/qmltests/tst_Shell.qml 2014-08-25 13:10:38 +0000
63+++ tests/qmltests/tst_Shell.qml 2014-08-28 20:00:25 +0000
64@@ -389,13 +389,14 @@
65 tryCompare(indicators, "fullyClosed", true);
66 }
67
68-
69- function test_showGreeterDBusCall() {
70+ function test_showAndHideGreeterDBusCalls() {
71 var greeter = findChild(shell, "greeter")
72 tryCompare(greeter, "showProgress", 0)
73 waitForRendering(greeter);
74 LightDM.Greeter.showGreeter()
75 tryCompare(greeter, "showProgress", 1)
76+ LightDM.Greeter.hideGreeter()
77+ tryCompare(greeter, "showProgress", 0)
78 }
79
80 function test_login() {
81
82=== modified file 'tools/unlock-device'
83--- tools/unlock-device 2014-06-11 15:36:51 +0000
84+++ tools/unlock-device 2014-08-28 20:00:25 +0000
85@@ -4,7 +4,7 @@
86 # Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
87 # This will include a reboot.
88
89-WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
90+WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device"
91
92 while getopts s:w: opt; do
93 case $opt in
94@@ -17,20 +17,15 @@
95 esac
96 done
97
98-UNLOCK_SCRIPT='
99-import dbus, logging;
100-from unity8 import process_helpers as helpers;
101-logging.basicConfig(level=logging.INFO);
102-bus = dbus.SystemBus().get_object("com.canonical.powerd", "/com/canonical/powerd");
103-cookie = bus.requestSysState("unlock-device-hold", 1, dbus_interface="com.canonical.powerd");
104-helpers.restart_unity_with_testability();
105-bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
106-helpers.unlock_unity()
107-'
108-
109 eval "$WAIT_COMMAND"
110
111-UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
112+# Force a sleep of twenty no matter what, since we may need to wait for unity8
113+# to finish coming up (it's hard to tell when the greeter is actually rendered)
114+sleep 20
115+
116+GDBUS_CMD="gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked"
117+
118+UNLOCK_OUTPUT=$(adb shell "if [ \"\$(id -u)\" = 0 ]; then sudo -u phablet -i $GDBUS_CMD; else $GDBUS_CMD; fi" 2>&1)
119 if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
120 echo "I: Unlock passed"
121 exit 0

Subscribers

People subscribed via source and target branches