pam_auth.c 1.4 KB

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