Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
03-02-2005, 03:54 AM
|
#1
|
|
Member
Registered: Mar 2005
Posts: 61
Rep:
|
Password Authentication Application
hi all,
I'm Rajesh new to this mailing list. I'm trying out to write an application to authenticate "User name" & "Password" in Suse Linux, what we get in login console. Is there any system calls or APIs in Suse Linux to verify the user and allow him/her to log in...??
Please help me out .....
|
|
|
|
03-03-2005, 12:22 AM
|
#2
|
|
Member
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95
Rep:
|
hi rajesh,
For authenticating the linux username, you need to encrypt the password and check with the entry in the /etc/shadow. So u will need root privileges for ur application.
getspnam(username) is a call which will return a structure spwd, which will contain the info related to the user. Then u need to encrypt the password the user has entered and compare it with the one in the structure.
I have done this some time back in RedHat, but i believe shd work for Suse also.
HTH
|
|
|
|
03-04-2005, 12:15 AM
|
#3
|
|
Member
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95
Rep:
|
hi,
I couldnt find the source code in C. I tried rewriting. Encountered some prob. Didnt have time to debug.
See if this perl snippet will be of use for u. This was given by my friend.
< code>
#!/usr/bin/perl -w
$user = $ARGV[0];
$pass = $ARGV[1];
open(PASS,"/etc/shadow") or die "cant open file";
while($Lines=<PASS>)
{
@me=split(/:/,$Lines);
if ($me[0] eq $user)
{
if (crypt ($pass,$me[1]) eq $me[1])
{
print "Password is correct\n";
last;
}
else
{
print "Password is incorrect\n";
last;
}
}
}
close(PASS);
< /code>
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:54 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|