Dropping privileges

A

Andrea Crotti

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
 
N

Nobody

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top