Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


LinkBack Search this Thread
Old 03-02-2005, 03:54 AM   #1
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, 12:22 AM   #2
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.

Old 03-04-2005, 12:15 AM   #3
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95

Rep: Reputation: 15
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";
if ($me[0] eq $user)
if (crypt ($pass,$me[1]) eq $me[1])
print "Password is correct\n";
print "Password is incorrect\n";

< /code>


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

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

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