Quote:
Originally Posted by noctilucent
1. Why not let su/sudo/whatever take care of it in the first place?
2. Check out the permissions on /bin/su - notice anything 'special' about that?
3. Two words for you: open source. Have you looked through the source of `su` and similar tools to see what they do with the password they receive from the user?
|
I am just debriefing what noctilucent has said.
If I am correct, only programs run from root can gain root privileges, no other program can gain root privilege in any other way.
the programs su, sudo run with 'setuid' bit making them run with root privileges no matter which user starts. May be you too should 'setuid' your program to run as root. For the authorization you can do a md5 on the password entered and check with the /etc/shadow file. To deny access, just exit the program when the password digest doesn't match.