Mercurial > dovecot > original-hg > dovecot-1.2
view src/auth/passdb-bsdauth.c @ 3257:92c16e82b806 HEAD
passdb can now change the username that was used to log in. This is mostly
useful to support case-insensitive username lookups.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 03 Apr 2005 01:00:49 +0300 |
parents | e6a487d80288 |
children | 9096b7957413 |
line wrap: on
line source
/* Copyright (C) 2002-2003 Timo Sirainen */ #include "config.h" #undef HAVE_CONFIG_H #ifdef PASSDB_BSDAUTH #include "common.h" #include "safe-memset.h" #include "passdb.h" #include "mycrypt.h" #include <login_cap.h> #include <bsd_auth.h> #include <pwd.h> static void bsdauth_verify_plain(struct auth_request *request, const char *password, verify_plain_callback_t *callback) { struct passwd *pw; int result; pw = getpwnam(request->user); if (pw == NULL) { auth_request_log_info(request, "bsdauth", "unknown user"); callback(PASSDB_RESULT_USER_UNKNOWN, request); return; } if (!IS_VALID_PASSWD(pw->pw_passwd)) { auth_request_log_info(request, "bsdauth", "invalid password field"); callback(PASSDB_RESULT_USER_DISABLED, request); return; } /* check if the password is valid */ result = auth_userokay(request->user, NULL, NULL, t_strdup_noconst(password)); /* clear the passwords from memory */ safe_memset(pw->pw_passwd, 0, strlen(pw->pw_passwd)); if (!result) { auth_request_log_info(request, "bsdauth", "password mismatch"); callback(PASSDB_RESULT_PASSWORD_MISMATCH, request); return; } /* make sure we're using the username exactly as it's in the database */ request->user = p_strdup(request->pool, pw->pw_name); callback(PASSDB_RESULT_OK, request); } static void bsdauth_deinit(void) { endpwent(); } struct passdb_module passdb_bsdauth = { "bsdauth", "%u", "CRYPT", FALSE, NULL, NULL, bsdauth_deinit, bsdauth_verify_plain, NULL }; #endif