From c3a84e4ccb46e2b13d5b2341c09f1b813f987c06 Mon Sep 17 00:00:00 2001 From: "mathias.gumz" Date: Tue, 7 Oct 2008 16:37:33 +0000 Subject: [PATCH] fix for overlapping penalty from auth-backends (eg pam's 3s timeout on wrong passwd) and alock itself --HG-- extra : convert_revision : svn%3Aeebe1cee-a9af-4fe4-bd26-ad572b19c5ab/trunk%4083 --- src/alock.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/alock.c b/src/alock.c index 52e30ef..b5f02fe 100644 --- a/src/alock.c +++ b/src/alock.c @@ -283,18 +283,30 @@ static int eventLoop(struct aOpts* opts, struct aXInfo* xi) { if (rlen < sizeof(rbuf)) rbuf[rlen] = 0; + // some auth() methods have their own penalty system + // so we assume that the auth() fails, visualize 'failed' + // for as long as the auth needs. + // + // if it comes back 'ok', the visualization frame is + // destroyed anyway. if it comes back 'false', then + // we would need to show it anyway + we measure the + // auth() penalty time to use it for the timeout. + + mode = WRONG; + visualFeedback(frame, mode); + XSync(dpy, True); + XBell(dpy, 0); + if (opts->auth->auth(rbuf)) { alock_free_frame(frame); return 1; } - mode = WRONG; + timeout = last_key_time; + if (elapsedTime() - last_key_time < penalty) + timeout += penalty; - XSync(dpy, True); /* discard pending events to start really fresh */ - XBell(dpy, 0); rlen = 0; - - timeout = last_key_time + penalty; break; default: