Mercurial > dovecot > original-hg > dovecot-1.2
view src/auth/otp-skey-common.c @ 4891:6ab2712f1a93 HEAD
Only imap binary was actually working.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 10 Dec 2006 14:35:02 +0200 |
parents | c04189d77a59 |
children | e33a87152c41 |
line wrap: on
line source
/* * Common code for OTP and SKEY authentication mechanisms. * * Copyright (c) 2006 Andrey Panin <pazke@donpac.ru> * * This software is released under the MIT license. */ #include "common.h" #include "hash.h" #include "mech.h" #include "otp.h" #include "otp-skey-common.h" static struct hash_table *otp_lock_table; void otp_lock_init(void) { if (otp_lock_table != NULL) return; otp_lock_table = hash_create(system_pool, system_pool, 128, strcase_hash, (hash_cmp_callback_t *)strcasecmp); } int otp_try_lock(struct auth_request *auth_request) { if (hash_lookup(otp_lock_table, auth_request->user)) return FALSE; hash_insert(otp_lock_table, auth_request->user, auth_request); return TRUE; } void otp_unlock(struct auth_request *auth_request) { struct otp_auth_request *request = (struct otp_auth_request *)auth_request; if (!request->lock) return; hash_remove(otp_lock_table, auth_request->user); request->lock = FALSE; } void otp_set_credentials_callback(enum passdb_result result, struct auth_request *auth_request) { switch (result) { case PASSDB_RESULT_OK: auth_request_success(auth_request, NULL, 0); break; default: auth_request_internal_failure(auth_request); otp_unlock(auth_request); break; } otp_unlock(auth_request); } void mech_otp_skey_auth_free(struct auth_request *auth_request) { otp_unlock(auth_request); pool_unref(auth_request->pool); }