diff --git a/include/common/hathreads.h b/include/common/hathreads.h index 1f3fe8dd6..d2fd400e0 100644 --- a/include/common/hathreads.h +++ b/include/common/hathreads.h @@ -386,6 +386,7 @@ enum lock_label { PIPES_LOCK, START_LOCK, TLSKEYS_REF_LOCK, + AUTH_LOCK, LOCK_LABELS }; struct lock_stat { @@ -501,6 +502,7 @@ static inline const char *lock_label(enum lock_label label) case PIPES_LOCK: return "PIPES"; case START_LOCK: return "START"; case TLSKEYS_REF_LOCK: return "TLSKEYS_REF"; + case AUTH_LOCK: return "AUTH"; case LOCK_LABELS: break; /* keep compiler happy */ }; /* only way to come here is consecutive to an internal bug */ diff --git a/src/auth.c b/src/auth.c index 3dd3a1de0..599a3abbc 100644 --- a/src/auth.c +++ b/src/auth.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,10 @@ struct userlist *userlist = NULL; /* list of all existing userlists */ +#ifdef CONFIG_HAP_CRYPT +__decl_hathreads(static HA_SPINLOCK_T auth_lock); +#endif + /* find targets for selected gropus. The function returns pointer to * the userlist struct ot NULL if name is NULL/empty or unresolvable. */ @@ -245,7 +250,9 @@ check_user(struct userlist *ul, const char *user, const char *pass) if (!(u->flags & AU_O_INSECURE)) { #ifdef CONFIG_HAP_CRYPT + HA_SPIN_LOCK(AUTH_LOCK, &auth_lock); ep = crypt(pass, u->pass); + HA_SPIN_UNLOCK(AUTH_LOCK, &auth_lock); #else return 0; #endif