Hi,

  I'm writing a program where I need to validate a users password.
Right now I'm using crypt and code like the following:

pentry is a pointer to a passwd struct obtained by using the users
userid.

err is in a int initialized to 0;
userpass is a c string containing the users plaintext password.

        if ( pentry == NULL ) {
        perror("I couldn't get your encrypted password.");
                return err;
        }

        salt[0] = pentry->pw_passwd[0];
        salt[1] = pentry->pw_passwd[1];
        salt[2] = '\0';

        usercrypt = crypt(userpass, salt);
        if ((err = strcmp(usercrypt, pentry->pw_passwd)) == 0) {

the strcmp always returns unsuccessful even though I know the passwd I
put in when I try it is correct. Is there something funky I have to do b/c 
I'm using shadow passwd's and pam? The pw_passwd shows up in the debugger
as "x" instead of the encrypted version of the passwd.

I could use another set of eyeballs :)

Thanks.

-- 
===========================================================
"... all thoughts of selfish desire, ill-will, hatred and
 violence are the result of a lack of wisdom ... "
 - Buddha

For an awsome fantasy role playing game checkout:
http://members.xoom.com/Lycadican
===========================================================

Reply via email to