on xenial help sign in
Better handle wrong password attempts
251731dMichael Terry
qml/Components/PassphraseLockscreen.qml+3
@@ -31,8 +31,10 @@ Item {
31
31
32 function clear(playAnimation) {
32 function clear(playAnimation) {
33 pinentryField.text = "";
33 pinentryField.text = "";
34+ pinentryField.enabled = true
34 if (playAnimation) {
35 if (playAnimation) {
35 wrongPasswordAnimation.start();
36 wrongPasswordAnimation.start();
37+ pinentryField.forceActiveFocus();
36 } else {
38 } else {
37 pinentryField.focus = false
39 pinentryField.focus = false
38 }
40 }
@@ -78,6 +80,7 @@ Item {
78
80
79 onAccepted: {
81 onAccepted: {
80 if (pinentryField.text) {
82 if (pinentryField.text) {
83+ pinentryField.enabled = false;
81 root.entered(pinentryField.text);
84 root.entered(pinentryField.text);
82 }
85 }
83 }
86 }
qml/Shell.qml+7−6
@@ -364,7 +364,7 @@ FocusScope {
364 onShownChanged: if (shown) greeter.fakeActiveForApp = ""
364 onShownChanged: if (shown) greeter.fakeActiveForApp = ""
365
365
366 Component.onCompleted: {
366 Component.onCompleted: {
367− if (LightDM.Users.count == 1) {
367+ if (greeter.narrowMode) {
368 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
368 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
369 }
369 }
370 }
370 }
@@ -376,8 +376,8 @@ FocusScope {
376 onShowGreeter: greeter.show()
376 onShowGreeter: greeter.show()
377
377
378 onShowPrompt: {
378 onShowPrompt: {
379− if (LightDM.Users.count == 1) {
379+ if (greeter.narrowMode) {
380− lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
380+ lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text.toLowerCase());
381 lockscreen.show();
381 lockscreen.show();
382 }
382 }
383 }
383 }
@@ -391,6 +391,9 @@ FocusScope {
391 greeter.login();
391 greeter.login();
392 } else {
392 } else {
393 lockscreen.clear(true);
393 lockscreen.clear(true);
394+ if (greeter.narrowMode) {
395+ LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
396+ }
394 }
397 }
395 }
398 }
396 }
399 }
@@ -459,9 +462,7 @@ FocusScope {
459 if (!LightDM.Greeter.promptless) {
462 if (!LightDM.Greeter.promptless) {
460 lockscreen.show();
463 lockscreen.show();
461 }
464 }
462− // If there is only one user, we start authenticating with that one here.
465+ if (greeter.narrowMode) {
463− // If there are more users, the Greeter will handle that
464− if (LightDM.Users.count == 1) {
465 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
466 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
466 }
467 }
467 greeter.fakeActiveForApp = "";
468 greeter.fakeActiveForApp = "";
tests/mocks/LightDM/demo/GreeterPrivate.cpp+18−1
@@ -54,6 +54,16 @@ public:
54
54
55 void start(QString username)
55 void start(QString username)
56 {
56 {
57+ // Clear out any existing PAM interactions first (we can't simply
58+ // cancel our QFuture because QtConcurrent::run doesn't support cancel)
59+ if (pamHandle != NULL) {
60+ pam_handle *handle = pamHandle;
61+ pamHandle = NULL; // to disable normal finishPam() handling
62+ while (respond(QString())); // clear our local queue of QFutures
63+ pam_end(handle, PAM_CONV_ERR);
64+ }
65+
66+ // Now actually start a new conversation with PAM
57 pam_conv conversation;
67 pam_conv conversation;
58 conversation.conv = converseWithPam;
68 conversation.conv = converseWithPam;
59 conversation.appdata_ptr = static_cast<void*>(this);
69 conversation.appdata_ptr = static_cast<void*>(this);
@@ -158,10 +168,13 @@ public:
158 }
168 }
159
169
160public Q_SLOTS:
170public Q_SLOTS:
161− void respond(QString response)
171+ bool respond(QString response)
162 {
172 {
163 if (!futures.isEmpty()) {
173 if (!futures.isEmpty()) {
164 futures.dequeue().reportFinished(&response);
174 futures.dequeue().reportFinished(&response);
175+ return true;
176+ } else {
177+ return false;
165 }
178 }
166 }
179 }
167
180
@@ -172,6 +185,10 @@ Q_SIGNALS:
172private Q_SLOTS:
185private Q_SLOTS:
173 void finishPam()
186 void finishPam()
174 {
187 {
188+ if (pamHandle == NULL) {
189+ return;
190+ }
191+
175 int pamStatus = futureWatcher.result();
192 int pamStatus = futureWatcher.result();
176
193
177 pam_end(pamHandle, pamStatus);
194 pam_end(pamHandle, pamStatus);