Mercurial > dovecot > original-hg > dovecot-1.2
view src/auth/userinfo-shadow.c @ 805:5ac361acb316 HEAD
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
cleanups and a couple of minor bugfixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 18 Dec 2002 17:15:41 +0200 |
parents | bf38c8f30a4c |
children | fd8888f6f037 |
line wrap: on
line source
/* Loosely based on auth_shadow.c from popa3d by Solar Designer <solar@openwall.com> Copyright (C) 2002 Timo Sirainen */ #include "config.h" #undef HAVE_CONFIG_H #ifdef USERINFO_SHADOW #include "userinfo-passwd.h" #include "mycrypt.h" #include <shadow.h> static int shadow_verify_plain(const char *user, const char *password, AuthCookieReplyData *reply) { struct passwd *pw; struct spwd *spw; int result; spw = getspnam(user); if (spw == NULL || !IS_VALID_PASSWD(spw->sp_pwdp)) return FALSE; /* check if the password is valid */ result = strcmp(mycrypt(password, spw->sp_pwdp), spw->sp_pwdp) == 0; /* clear the passwords from memory */ safe_memset(spw->sp_pwdp, 0, strlen(spw->sp_pwdp)); if (!result) return FALSE; /* password ok, save the user info */ pw = getpwnam(user); if (pw == NULL) return FALSE; passwd_fill_cookie_reply(pw, reply); return TRUE; } static void shadow_deinit(void) { endpwent(); endspent(); } UserInfoModule userinfo_shadow = { NULL, shadow_deinit, shadow_verify_plain, NULL }; #endif