on xenial help sign in
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.

Approved by: Martin Pitt, Albert Astals Cid

commitc325074da6c1a14cc0a9dd8e468194021dbd8ef8 authorMichael Terry <michael.terry@canonical.com> dateThu 28 Aug 2014, 20:06 (12 years ago) parentbb8999c2197aba
6 files changed+19−16
plugins/LightDM/DBusGreeter.cpp+5 plugins/LightDM/DBusGreeter.h+1 plugins/LightDM/Greeter.h+1 qml/Shell.qml+1−1 tests/qmltests/tst_Shell.qml+3−2 tools/unlock-device+8−13
plugins/LightDM/DBusGreeter.cpp+5
@@ -39,6 +39,11 @@ void DBusGreeter::ShowGreeter()
3939 return Q_EMIT m_greeter->showGreeter();
4040}
4141
42+void DBusGreeter::HideGreeter()
43+{
44+ return Q_EMIT m_greeter->hideGreeter();
45+}
46+
4247void DBusGreeter::isActiveChangedHandler()
4348{
4449 notifyPropertyChanged("IsActive", isActive());
plugins/LightDM/DBusGreeter.h+1
@@ -38,6 +38,7 @@ public:
3838
3939 bool isActive() const;
4040 Q_SCRIPTABLE void ShowGreeter(); // temporary, until we split the greeter again
41+ Q_SCRIPTABLE void HideGreeter(); // temporary, until we split the greeter again
4142
4243Q_SIGNALS:
4344 void isActiveChanged();
plugins/LightDM/Greeter.h+1
@@ -62,6 +62,7 @@ Q_SIGNALS:
6262 void isAuthenticatedChanged();
6363 void promptlessChanged();
6464 void showGreeter();
65+ void hideGreeter();
6566
6667 // This signal is emitted by external agents like indicators, and the UI
6768 // should switch to this user if possible.
qml/Shell.qml+1−1
@@ -271,6 +271,7 @@ Item {
271271 target: LightDM.Greeter
272272
273273 onShowGreeter: greeter.show()
274+ onHideGreeter: greeter.login()
274275
275276 onShowPrompt: {
276277 if (greeter.narrowMode) {
@@ -313,7 +314,6 @@ Item {
313314 }
314315
315316 if (LightDM.Greeter.authenticated) {
316− lockscreen.hide();
317317 greeter.login();
318318 } else {
319319 AccountsService.failedLogins++
tests/qmltests/tst_Shell.qml+3−2
@@ -389,13 +389,14 @@ Item {
389389 tryCompare(indicators, "fullyClosed", true);
390390 }
391391
392−
393− function test_showGreeterDBusCall() {
392+ function test_showAndHideGreeterDBusCalls() {
394393 var greeter = findChild(shell, "greeter")
395394 tryCompare(greeter, "showProgress", 0)
396395 waitForRendering(greeter);
397396 LightDM.Greeter.showGreeter()
398397 tryCompare(greeter, "showProgress", 1)
398+ LightDM.Greeter.hideGreeter()
399+ tryCompare(greeter, "showProgress", 0)
399400 }
400401
401402 function test_login() {
tools/unlock-device+8−13
@@ -4,7 +4,7 @@
44# Our goal here is to get an Ubuntu Touch device into a testable unlocked state.
55# This will include a reboot.
66
7−WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device; sleep 20"
7+WAIT_COMMAND="adb reboot; sleep 5; adb wait-for-device"
88
99while getopts s:w: opt; do
1010 case $opt in
@@ -17,20 +17,15 @@ while getopts s:w: opt; do
1717 esac
1818done
1919
20−UNLOCK_SCRIPT='
21−import dbus, logging;
22−from unity8 import process_helpers as helpers;
23−logging.basicConfig(level=logging.INFO);
24−bus = dbus.SystemBus().get_object("com.canonical.powerd", "/com/canonical/powerd");
25−cookie = bus.requestSysState("unlock-device-hold", 1, dbus_interface="com.canonical.powerd");
26−helpers.restart_unity_with_testability();
27−bus.clearSysState(cookie, dbus_interface="com.canonical.powerd");
28−helpers.unlock_unity()
29−'
30−
3120eval "$WAIT_COMMAND"
3221
33−UNLOCK_OUTPUT=$(adb shell "sudo -u phablet -i python3 -c '$UNLOCK_SCRIPT'" 2>&1)
22+# Force a sleep of twenty no matter what, since we may need to wait for unity8
23+# to finish coming up (it's hard to tell when the greeter is actually rendered)
24+sleep 20
25+
26+GDBUS_CMD="gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter && echo Greeter unlocked"
27+
28+UNLOCK_OUTPUT=$(adb shell "if [ \"\$(id -u)\" = 0 ]; then sudo -u phablet -i $GDBUS_CMD; else $GDBUS_CMD; fi" 2>&1)
3429if echo "$UNLOCK_OUTPUT" | grep 'Greeter unlocked' >/dev/null; then
3530 echo "I: Unlock passed"
3631 exit 0