What is the best way to check if a root linux password is correct,from a c program.One solution is tu run a command like : echo \"myPass\n"\ | sudo -S mySudoPassword
and somehow check stderr to see if contains data.I am looking forward to get an elegant solution
Asked
Active
Viewed 2.3k times
1 Answers
2
You can validate that a given password is correct for a given username using the shadow file.
See Given a linux username and a password how can I test if it is a valid account? for the mechanics of how this is done. It should be possible to perform the same operations in a C program.
-
1but I can't the shadow file,if i am not root or at least my acoount is in the sudoers file.I want to check just for the root...not for every user. – Dec 26 '14 at 10:45