Dropping privileges

Discussion in 'C Programming' started by Andrea Crotti, Jul 31, 2010.

  1. My program now sadly runs only as root, but actually I think that the
    only thing that really needs root access is the creation of a tunnel
    device.

    Looking around I understood that I could use setuid() to drop the
    privileges after critical part is over, but to what user?

    I think this is the reason why mysql/openldap/etc creates new user, so
    they can drop down to it when they're done with critical part.

    But where exactly should this user cretion mechanism be set?
    Still from the C program (removing it when exiting)?
    Thanks
    Andrea Crotti, Jul 31, 2010
    #1
    1. Advertising

  2. Andrea Crotti

    Nobody Guest

    On Sat, 31 Jul 2010 16:08:58 +0200, Andrea Crotti wrote:

    > My program now sadly runs only as root, but actually I think that the
    > only thing that really needs root access is the creation of a tunnel
    > device.
    >
    > Looking around I understood that I could use setuid() to drop the
    > privileges after critical part is over, but to what user?
    >
    > I think this is the reason why mysql/openldap/etc creates new user, so
    > they can drop down to it when they're done with critical part.
    >
    > But where exactly should this user cretion mechanism be set?
    > Still from the C program (removing it when exiting)?


    First, you would do better to ask on comp.unix.programmer.

    You definitely shouldn't be creating and deleting accounts from within
    your program. Nowadays, such tasks are far more complex than they might
    appear. You can't assume that it's just a matter of adding a line to
    /etc/passwd, due to the use of NIS/LDAP/etc, or even integration with
    Windows domains. On Linux, creation of accounts to run daemons is normally
    handled by the package's installation script, and is specific to a given
    distribution.

    One issue with dropping down to an existing account such as daemon or adm
    is that the account may be a member of certain privileged groups, e.g. bin.
    Nobody, Jul 31, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Nassar

    Debugger privileges for ASP.NET

    Tony Nassar, Jan 26, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    1,718
    Tony Nassar
    Feb 12, 2004
  2. Shalini
    Replies:
    1
    Views:
    332
    Hernan de Lahitte
    Mar 5, 2004
  3. Matthew Smith

    Developer Account Privileges

    Matthew Smith, Jul 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    340
    Bryant Hankins
    Jul 19, 2004
  4. =?Utf-8?B?c2hlZmFsaQ==?=

    HTTPHandler to create, write file and account privileges

    =?Utf-8?B?c2hlZmFsaQ==?=, Dec 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    369
    =?Utf-8?B?c2hlZmFsaQ==?=
    Dec 2, 2004
  5. David Härdeman

    Dropping privileges in python daemon

    David Härdeman, Aug 18, 2008, in forum: Python
    Replies:
    1
    Views:
    399
    Matthias Bläsing
    Aug 18, 2008
Loading...

Share This Page