Solved

Unix password verification

Posted on 1997-11-18
3
307 Views
Last Modified: 2013-12-26
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.
0
Comment
Question by:ohp
3 Comments
 
LVL 10

Expert Comment

by:rbr
ID: 1295626
I know that this program is in some archive. Use archie and search for
passwd.c. This will lead to the right program.
0
 

Author Comment

by:ohp
ID: 1295627
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
 
LVL 4

Accepted Solution

by:
jos010697 earned 200 total points
ID: 1295628
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Complete beginner needs help making a cron job 9 104
sum13 challenge 24 77
changeXy challenge 13 57
Thin secure Windows 10 5 48
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now