LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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



Reply
 
Search this Thread
Old 03-02-2005, 04:54 AM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
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 .....
 
Old 03-03-2005, 01:22 AM   #2
hk_linux
Member
 
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95

Rep: Reputation: 15
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
 
Old 03-04-2005, 01:15 AM   #3
hk_linux
Member
 
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95

Rep: Reputation: 15
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>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
S-l-o-w password recognition/authentication jonr Mandriva 8 11-01-2003 02:49 PM
ssh with password authentication Nyarlathotep Linux - Security 4 10-06-2003 01:13 PM
email password authentication flynnt Linux - Security 1 09-11-2003 03:09 PM
email password authentication flynnt Linux - Networking 0 09-11-2003 02:02 AM
Password Authentication Server Tunarle Linux - Networking 1 07-27-2003 04:55 PM


All times are GMT -5. The time now is 03:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration