I'm writing a program that will need the user's password. The program should not have to be run as root, but it should work when run normally.
The user should type his login password, and the program should check if the password is right. I can't figure out how to do this. Can anybody help me?
int uid = getuid(); /* see who it is */
char[50] entered_passwd;
/* somehow check if entered_password is the user's password
* how do I do this?? */
if (password_is_correct) {
/* do something */
} else {
printf("Wrong!\n");
/* do something else */
}