adds delay if agent unlock failed
+#define _XOPEN_SOURCE 500
#include "lock_state.h"
#include "../lib/list/src/list.h"
#include <string.h>
#include <syslog.h>
+#include <unistd.h>
oidc_error_t unlock(list_t* loaded, const char* password) {
+ static unsigned char fail_count = 0;
syslog(LOG_AUTHPRIV | LOG_DEBUG, "Unlocking agent");
if (agent_state.lock_state.locked == 0) {
syslog(LOG_AUTHPRIV | LOG_DEBUG, "Agent not locked");
@@ -20,10 +23,19 @@ oidc_error_t unlock(list_t* loaded, const char* password) {
agent_state.lock_state.locked = 0;
secFreeHashed(agent_state.lock_state.hash);
lockDecrypt(loaded, password);
+ fail_count = 0;
syslog(LOG_AUTHPRIV | LOG_DEBUG, "Agent unlocked");
return OIDC_SUCCESS;
}
oidc_errno = OIDC_EPASS;
+ /* delay in 0.1s increments up to 10s */
+ if (fail_count < 100) {
+ fail_count++;
+ }
+ unsigned int delay = 100000 * fail_count;
+ syslog(LOG_AUTHPRIV | LOG_DEBUG, "unlock failed, delaying %0.1lf seconds",
+ (double)delay / 1000000);
+ usleep(delay);
return oidc_errno;
}
