userinfo-passwd.c revision 66251e6ab31e5cc153fe5cae608e416dacafe9cd
5717e8e12768ab1d667cd3e908e5f3ffe540655aTimo Sirainen Loosely based on auth_passwd.c from popa3d by
70267341ccf430f6c77646e69c24e33d111b65a8Pascal Volk Solar Designer <solar@openwall.com>
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk Copyright (C) 2002 Timo Sirainen
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk#define _XOPEN_VERSION 4 /* FIXME: needed? solaris throws warnings with it */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volkvoid passwd_fill_cookie_reply(struct passwd *pw, AuthCookieReplyData *reply)
88c816e8be4e1a29bca8b67d67a92c67a33f3795Timo Sirainen i_assert(sizeof(reply->user) > strlen(pw->pw_name));
e0579d45910f8a4ed55aa670f136db183344a786Timo Sirainen i_assert(sizeof(reply->home) > strlen(pw->pw_dir));
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volkstatic int passwd_verify_plain(const char *user, const char *password,
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk if (pw == NULL || !IS_VALID_PASSWD(pw->pw_passwd))
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* check if the password is valid */
28372fb7f889fbf9d0b5266f154f7f3004e26324Pascal Volk result = strcmp(crypt(passdup, pw->pw_passwd), pw->pw_passwd) == 0;
28372fb7f889fbf9d0b5266f154f7f3004e26324Pascal Volk /* clear the passwords from memory */
28372fb7f889fbf9d0b5266f154f7f3004e26324Pascal Volk memset(pw->pw_passwd, 0, strlen(pw->pw_passwd));
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* password ok, save the user info */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volkstatic void passwd_deinit(void)