Quote:
Originally Posted by abdel
hello,
I am creating a program to validate a user (similar to what login command does) and need to validate wether a user and password is valid or not. As far as i searched i got functions to trverse the passwd file.. the functions are
setpwent(),getpwnam(), and endpwent().. but these functions do not compare the user entered password string with the passwd file string..
somebody pls tell me how to compare and what functions should i use to do it...
|
Ok, first you read the user, then the password with getpass(), then you look up the encrypted password with getspnam(user) and you use sp_pwdp as the salt to call crypt(pass, sp->sp_pwdp). Then you compare the returned string to sp_pwdp. I hope I'm not missing anything.
PS: You may consider using the PAM framework. There are Howtos at
www.tldp.org