Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / contrib / libpam / libpam / pam_password.c
1 /* pam_password.c - PAM Password Management */
2
3 /*
4  * $Id: pam_password.c,v 1.7 1997/04/05 06:56:45 morgan Exp $
5  * $FreeBSD: src/contrib/libpam/libpam/pam_password.c,v 1.1.1.1.6.2 2001/06/11 15:28:12 markm Exp $
6  * $DragonFly: src/contrib/libpam/libpam/Attic/pam_password.c,v 1.2 2003/06/17 04:24:03 dillon Exp $
7  *
8  * $Log: pam_password.c,v $
9  */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include "pam_private.h"
15
16 int pam_chauthtok(pam_handle_t *pamh, int flags)
17 {
18     int retval;
19
20     D(("called."));
21
22     IF_NO_PAMH("pam_chauthtok", pamh, PAM_SYSTEM_ERR);
23
24     if (pamh->former.choice == PAM_NOT_STACKED) {
25         _pam_start_timer(pamh);    /* we try to make the time for a failure
26                                       independent of the time it takes to
27                                       fail */
28         _pam_sanitize(pamh);
29         pamh->former.update = PAM_FALSE;
30     }
31
32     /* first loop through to check if there will be a problem */
33     if (pamh->former.update ||
34         (retval = _pam_dispatch(pamh, flags|PAM_PRELIM_CHECK,
35                                 PAM_CHAUTHTOK)) == PAM_SUCCESS) {
36         pamh->former.update = PAM_TRUE;
37         retval = _pam_dispatch(pamh, flags|PAM_UPDATE_AUTHTOK,
38                                PAM_CHAUTHTOK);
39     }
40
41     /* if we completed we should clean up */
42     if (retval != PAM_INCOMPLETE) {
43         _pam_sanitize(pamh);
44         pamh->former.update = PAM_FALSE;
45         _pam_await_timer(pamh, retval);   /* if unsuccessful then wait now */
46         D(("pam_authenticate exit"));
47     } else {
48         D(("will resume when ready"));
49     }
50
51     return retval;
52 }
53