Results 1 to 2 of 2
I am writing a program which first runs as root but later switches itself to a normal user. And while running as normal user, it desires to call settimeofday(), which ...
- 11-04-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 7
How to grant user process some privilege capabilities
I am writing a program which first runs as root but later switches itself to a normal user. And while running as normal user, it desires to call settimeofday(), which only allows root to call.
Is there any solution for this?
I guess maybe there is a thing like this:
main()
{
//(1) - I am still root here
grant_capability_of_set_system_datetime();
//(2) - I am becoming a normal user now
setuid(400);
setgid(400);
//(3) - Set time here
settimeofday();
}
I guess getcap() and setcap() might do (1), but I couldn't find any usage example.
- 11-05-2008 #2Just Joined!
- Join Date
- Mar 2008
- Posts
- 7
I've just found this:
Using Capabilities
I'll tell if I can make it


Reply With Quote