LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   root login through system call(s) (https://www.linuxquestions.org/questions/linux-kernel-70/root-login-through-system-call-s-733522/)

hifun 06-17-2009 01:06 AM

root login through system call(s)
 
hi,
I want to give my process, superuser privileges on getting root password.
ie
If root execute this program and want to change it's privileges to normal user, getuid() and geteuid() will do the trick.
But if a normal user runs it then how the uid and euid can be changed to root via system calls?
eg.
It's just like , when shell changes it's uid , gid, euid etc. when normal user in his shell type su and <root password>.
HELP.
Thanks

noctilucent 06-17-2009 04:35 AM

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?

sreeharsha.t 06-17-2009 07:39 AM

Quote:

Originally Posted by noctilucent (Post 3576877)
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.

hifun 06-19-2009 07:49 PM

Thanks,
But if i simply do su it prompt for password and accept it.
on strace su , it asks for password but giving "password incorrect every time" so i am not able to check the syscalls.
Probably it might be calling setuid, setgid etc. Am i right?


All times are GMT -5. The time now is 04:02 PM.