In C, given userID and password, can I verify the user?
I have a C program used for authentication with an email server. The server passes the C program the username and password. Is there a function I can call, e.g. verify_user(username, password)?
|
More info: I've come across this link http://www.tldp.org/HOWTO/Shadow-Password-HOWTO-8.html which may or may not be what I am looking for. But, I do not have libshadow.a on my system, nor referenced headers like shadow/pwauth.h, but I do have shadow.h
I'm using Slackware64 14.1. The system says package shadow-4.1.5.1-x86_64-3_slack14.1 is installed. Need help! |
I figured it out. The following example assumes argv[1] is the username and argv[2] is the plain-text password to authenticate. Note that access to /etc/shadow can only be done as root. Compile the program below with:
$ gcc testauth.c -o testauth -lcrypt Code:
/* |
All times are GMT -5. The time now is 08:27 AM. |