Back to index

citadel  8.12
Functions
auth.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int validate_password (uid_t uid, const char *pass)

Function Documentation

int validate_password ( uid_t  uid,
const char *  pass 
)

Definition at line 98 of file auth.c.

{
#ifdef HAVE_PAM_START
       struct pam_conv pc;
       struct appdata data;
       pam_handle_t *ph;
       int i;
#else
       char *crypted_pwd;
#ifdef HAVE_GETSPNAM
       struct spwd *sp;
#endif
#endif
       struct passwd *pw;
       int retval = 0;
       int flags = 0;

#ifdef PAM_DATA_SILENT
       flags = PAM_DATA_SILENT;
#else
       flags = 0;
#endif /* PAM_DATA_SILENT */

       if ((pw = getpwuid(uid)) == NULL) {
              return retval;
       }

#ifdef HAVE_PAM_START
       pc.conv = conv;
       pc.appdata_ptr = &data;
       data.name = pw->pw_name;
       data.pw = pass;
       if (pam_start("citadel", pw->pw_name, &pc, &ph) != PAM_SUCCESS)
              return retval;

       if ((i = pam_authenticate(ph, flags)) == PAM_SUCCESS)
              if ((i = pam_acct_mgmt(ph, flags)) == PAM_SUCCESS)
                     retval = -1;

       pam_end(ph, i | flags);
#else
       crypted_pwd = pw->pw_passwd;

#ifdef HAVE_GETSPNAM
       if ((sp = getspnam(pw->pw_name)) != NULL)
              crypted_pwd = sp->sp_pwdp;
#endif

       if (!strcmp(crypt(pass, crypted_pwd), crypted_pwd))
              retval = -1;
#endif                      /* HAVE_PAM_START */

       return retval;
}

Here is the caller graph for this function: