Find the answer to your Linux question:
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 ...
  1. #1
    Just 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.

  2. #2
    Just Joined!
    Join Date
    Mar 2008
    Posts
    7
    I've just found this:

    Using Capabilities

    I'll tell if I can make it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...