Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libpam / libpam / pam_auth.c
CommitLineData
984263bc
MD
1/*
2 * pam_auth.c -- PAM authentication
3 *
4 * $Id: pam_auth.c,v 1.7 1997/04/05 06:53:52 morgan Exp morgan $
5 * $FreeBSD: src/contrib/libpam/libpam/pam_auth.c,v 1.1.1.1.6.2 2001/06/11 15:28:12 markm Exp $
6 *
7 * $Log: pam_auth.c,v $
8 * Revision 1.7 1997/04/05 06:53:52 morgan
9 * fail-delay changes
10 *
11 */
12
13#include <stdio.h>
14#include <stdlib.h>
15
16#include "pam_private.h"
17
18int pam_authenticate(pam_handle_t *pamh, int flags)
19{
20 int retval;
21
22 D(("pam_authenticate called"));
23
24 if (pamh->former.choice == PAM_NOT_STACKED) {
25 _pam_sanitize(pamh);
26 _pam_start_timer(pamh); /* we try to make the time for a failure
27 independent of the time it takes to
28 fail */
29 }
30
31 IF_NO_PAMH("pam_authenticate",pamh,PAM_SYSTEM_ERR);
32 retval = _pam_dispatch(pamh, flags, PAM_AUTHENTICATE);
33
34 if (retval != PAM_INCOMPLETE) {
35 _pam_sanitize(pamh);
36 _pam_await_timer(pamh, retval); /* if unsuccessful then wait now */
37 D(("pam_authenticate exit"));
38 } else {
39 D(("will resume when ready"));
40 }
41
42 return retval;
43}
44
45int pam_setcred(pam_handle_t *pamh, int flags)
46{
47 int retval;
48
49 IF_NO_PAMH("pam_setcred", pamh, PAM_SYSTEM_ERR);
50
51 D(("pam_setcred called"));
52
53 if (! flags) {
54 flags = PAM_ESTABLISH_CRED;
55 }
56
57 retval = _pam_dispatch(pamh, flags, PAM_SETCRED);
58
59 D(("pam_setcred exit"));
60
61 return retval;
62}