Mercurial > dovecot > original-hg > dovecot-1.2
view src/auth/mech-login.c @ 9415:2a48aa6e2bce HEAD
Added signature for changeset 609fe4268f40
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 05 Oct 2009 19:52:13 -0400 |
parents | 84eea1977632 |
children |
line wrap: on
line source
/* * LOGIN authentication mechanism. * * Copyright (c) 2004 Andrey Panin <pazke@donpac.ru> * * This software is released under the MIT license. */ #include "common.h" #include "mech.h" #include "passdb.h" #include "safe-memset.h" #include "plain-common.h" static void mech_login_auth_continue(struct auth_request *request, const unsigned char *data, size_t data_size) { static const char prompt2[] = "Password:"; const char *username, *error; if (request->user == NULL) { username = t_strndup(data, data_size); if (!auth_request_set_username(request, username, &error)) { auth_request_log_info(request, "login", "%s", error); auth_request_fail(request); return; } request->callback(request, AUTH_CLIENT_RESULT_CONTINUE, prompt2, strlen(prompt2)); } else { char *pass = p_strndup(unsafe_data_stack_pool, data, data_size); auth_request_verify_plain(request, pass, plain_verify_callback); safe_memset(pass, 0, strlen(pass)); } } static void mech_login_auth_initial(struct auth_request *request, const unsigned char *data, size_t data_size) { static const char prompt1[] = "Username:"; if (data_size == 0) { request->callback(request, AUTH_CLIENT_RESULT_CONTINUE, prompt1, strlen(prompt1)); } else { mech_login_auth_continue(request, data, data_size); } } static struct auth_request *mech_login_auth_new(void) { struct auth_request *request; pool_t pool; pool = pool_alloconly_create("login_auth_request", 1024); request = p_new(pool, struct auth_request, 1); request->pool = pool; return request; } const struct mech_module mech_login = { "LOGIN", MEMBER(flags) MECH_SEC_PLAINTEXT, MEMBER(passdb_need) MECH_PASSDB_NEED_VERIFY_PLAIN, mech_login_auth_new, mech_login_auth_initial, mech_login_auth_continue, mech_generic_auth_free };