on xenial help sign in
Initial pass at trying to fix reported lockout bug
commit09a4e7d1c5f97fbf42ec813899ff45115f14b948 authorMichael Terry <michael.terry@canonical.com> dateThu 10 Dec 2015, 16:33 (11 years ago) parentd76d469
1 file changed+18−17
qml/Greeter/Greeter.qml+18−17
qml/Greeter/Greeter.qml+18−17
@@ -216,36 +216,37 @@ Showable {
216216 }
217217
218218 onTriggered: {
219− var diff = delayTarget - new Date();
220− if (diff > 0) {
221− delayMinutes = Math.ceil(diff / 60000);
222− start(); // go again
223− } else {
224− delayMinutes = 0;
225− }
226− }
227−
228− function checkForForcedDelay() {
229219 var now = new Date();
230− delayTarget = now;
231− delayTarget.setTime(greeterSettings.lockedOutTime + failedLoginsDelayMinutes * 60000);
220+
221+ // We're going to compare stored time to system time here.
222+ // - We do this every tick (rather than just once at the start)
223+ // because clock time can change while we're running. For example,
224+ // ntpdate runs as an ifupdown script.
225+ // - And we trust this check because if a malicious actor is able
226+ // to manipulate time to avoid our lockout, there's not much we
227+ // can do to stop them.
232228
233229 // If tooEarly is true, something went very wrong. Bug or NTP
234230 // misconfiguration maybe?
235231 var tooEarly = now.getTime() < greeterSettings.lockedOutTime;
236− var tooLate = now > delayTarget;
232+ var tooLate = now >= delayTarget;
237233
238− // Compare stored time to system time. If a malicious actor is
239− // able to manipulate time to avoid our lockout, they already have
240− // enough access to cause damage. So we choose to trust this check.
241234 if (tooEarly || tooLate) {
242235 stop();
243236 delayMinutes = 0;
244237 } else {
245− triggered();
238+ var diff = delayTarget - now;
239+ delayMinutes = Math.ceil(diff / 60000);
240+ start(); // go again
246241 }
247242 }
248243
244+ function checkForForcedDelay() {
245+ delayTarget = new Date();
246+ delayTarget.setTime(greeterSettings.lockedOutTime + failedLoginsDelayMinutes * 60000);
247+ triggered();
248+ }
249+
249250 Component.onCompleted: checkForForcedDelay()
250251 }
251252