From 7d51eed316e6f45335d76a40f91ac11604a7764c Mon Sep 17 00:00:00 2001 From: davidadeleon <56207066+davidadeleon@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:59:48 +0000 Subject: [PATCH] backport of commit 2f8e59c8561aa561af12db87f54ac9c697c6b678 --- vault/logical_system_user_lockout.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vault/logical_system_user_lockout.go b/vault/logical_system_user_lockout.go index de2f6534649a..3e447b58ab3a 100644 --- a/vault/logical_system_user_lockout.go +++ b/vault/logical_system_user_lockout.go @@ -51,14 +51,16 @@ func unlockUser(ctx context.Context, core *Core, mountAccessor string, aliasName return err } - // Check if we have no more locked users and cancel any running lockout logger - core.userFailedLoginInfoLock.RLock() - numLockedUsers := len(core.userFailedLoginInfo) - core.userFailedLoginInfoLock.RUnlock() - - if numLockedUsers == 0 { - core.Logger().Info("user lockout(s) cleared") - core.lockoutLoggerCancel() + if core.lockoutLoggerCancel != nil { + // Check if we have no more locked users and cancel any running lockout logger + core.userFailedLoginInfoLock.RLock() + numLockedUsers := len(core.userFailedLoginInfo) + core.userFailedLoginInfoLock.RUnlock() + + if numLockedUsers == 0 { + core.Logger().Info("user lockout(s) cleared") + core.lockoutLoggerCancel() + } } return nil