yoda.techies@gmail.com wrote:
> hi
> i want to develop a program in C with gtk frontend , which is run
> under normal user privilges and want to have root privileges and i want
> to run some commands like lsmod etc. After finishing up the commands
> processing like lsmod i want come back to normal privileges program. I
> want to restore the user privileges to the program. How to implement
> it? please help me.
> mail me to yoda.techies@gmail.com
You should make the program owned by root and have the setuid bit on.
The code is then able to change its effective UID between the user
and root with the seteuid() system call.
For module listing, you do not need root privileges, it suffices to open
and read the file /proc/modules. For testing, just do
cat /proc/modules
--
Tauno Voipio
tauno voipio (at) iki fi