Move OTP synchronization step to after counter writeback

This prevents synchronization when an authentication collision occurs.

https://fedorahosted.org/freeipa/ticket/4493

Reviewed-By: Thierry bordaz (tbordaz) <tbordaz@redhat.com>
This commit is contained in:
Nathaniel McCallum
2014-09-19 12:18:34 -04:00
committed by Petr Viktorin
parent 9ba33971fa
commit 915837c14a

View File

@@ -202,17 +202,6 @@ static bool validate(struct otptoken *token, time_t now, ssize_t step,
if (*second != tmp)
return false;
/* Perform optional synchronization steps. */
switch (token->type) {
case OTPTOKEN_TOTP:
tmp = (step - now / token->totp.step) * token->totp.step;
if (!writeattr(token, T("clockOffset"), tmp))
return false;
break;
default:
break;
}
}
/* Write the step value. */
@@ -222,6 +211,13 @@ static bool validate(struct otptoken *token, time_t now, ssize_t step,
/* Save our modifications to the object. */
switch (token->type) {
case OTPTOKEN_TOTP:
/* Perform optional synchronization steps. */
if (second != NULL) {
tmp = (step - now / token->totp.step) * token->totp.step;
if (!writeattr(token, T("clockOffset"), tmp))
return false;
token->totp.offset = tmp;
}
token->totp.watermark = step;
break;
case OTPTOKEN_HOTP: