(root)/
Linux-PAM-1.5.3/
libpam/
pam_auth.c
       1  /*
       2   * pam_auth.c -- PAM authentication
       3   *
       4   * $Id$
       5   *
       6   */
       7  
       8  #include "pam_private.h"
       9  #include "pam_prelude.h"
      10  
      11  #include <stdio.h>
      12  #include <stdlib.h>
      13  
      14  int pam_authenticate(pam_handle_t *pamh, int flags)
      15  {
      16      int retval;
      17  
      18      D(("pam_authenticate called"));
      19  
      20      IF_NO_PAMH("pam_authenticate", pamh, PAM_SYSTEM_ERR);
      21  
      22      if (__PAM_FROM_MODULE(pamh)) {
      23  	D(("called from module!?"));
      24  	return PAM_SYSTEM_ERR;
      25      }
      26  
      27      if (pamh->former.choice == PAM_NOT_STACKED) {
      28  	_pam_sanitize(pamh);
      29  	_pam_start_timer(pamh);    /* we try to make the time for a failure
      30  				      independent of the time it takes to
      31  				      fail */
      32      }
      33  
      34      retval = _pam_dispatch(pamh, flags, PAM_AUTHENTICATE);
      35  
      36      if (retval != PAM_INCOMPLETE) {
      37  	_pam_sanitize(pamh);
      38  	_pam_await_timer(pamh, retval);   /* if unsuccessful then wait now */
      39  	D(("pam_authenticate exit"));
      40      } else {
      41  	D(("will resume when ready"));
      42      }
      43  
      44  #ifdef PRELUDE
      45      prelude_send_alert(pamh, retval);
      46  #endif
      47  
      48      return retval;
      49  }
      50  
      51  int pam_setcred(pam_handle_t *pamh, int flags)
      52  {
      53      int retval;
      54  
      55      D(("pam_setcred called"));
      56  
      57      IF_NO_PAMH("pam_setcred", pamh, PAM_SYSTEM_ERR);
      58  
      59      if (__PAM_FROM_MODULE(pamh)) {
      60  	D(("called from module!?"));
      61  	return PAM_SYSTEM_ERR;
      62      }
      63  
      64      if (! flags) {
      65  	flags = PAM_ESTABLISH_CRED;
      66      }
      67  
      68      retval = _pam_dispatch(pamh, flags, PAM_SETCRED);
      69  
      70      D(("pam_setcred exit"));
      71  
      72      return retval;
      73  }