Solved

Unix password verification

Posted on 1997-11-18
3
308 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
sameEnds challenge 3 136
Modbus - whats the maximum I can store in one register? 4 78
Not needed 13 95
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

19 Experts available now in Live!

Get 1:1 Help Now