Unix password verification

I found a little program on on web that checked the password giving the username and a password, it would return 0 or one.

I lost the source! I need it to authentificate from an other file.
ohpAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jos010697Connect With a Mentor Commented:
Shadow files are a different cup of tea; you need _access_
rights to get to that file (normally the root does).
The rest of the checking (if you have access to that file)
is a piece of cake:

char passwd[32];    /* contains a possible password */
char salt[3];       /* crypt() likes it spicy */
struct passwd* pw;  

pw= getpwuid(getuid()); /* or use getpwnam() if username known */

strncpy(salt, pw->pw_passwd, 2); /* get the 'salt' part */
salt[2]= '\0';

if (strcmp(crypt(passwd, salt), pw->pw_passwd))
   return 0; /* not a valid password */
else
   return 1;



0
 
rbrCommented:
I know that this program is in some archive. Use archie and search for
passwd.c. This will lead to the right program.
0
 
ohpAuthor Commented:
the passwd.c program changes a password. I could live with that,
but it doesn't deal with shadow file.

If my memery serves me well. I found this program on livingston WEB. But cant find it anymore!

0
All Courses

From novice to tech pro — start learning today.