I'm trying to create a service that starts a process.
I want the startup of the process to be able to do a few commands as root and then run the rest of the process as a less privileged non-human user.
For example: I know the apache
user requires some root privileges to do some web server configuration with ports and starting various server processes but it does not run as root all the time. I can't find any code that does something similar to this and was wondering if there are any other examples I can use.
Essentially my question is, how do I grant a non-root user temporary root privileges to run specific root only processes?
Or am I thinking about this the wrong way: Do I not grant the user root privileges and instead have the root user run the root-required processes?
root
can always drop its privileges by changing its GID and UID to a less privileged user. seeman setgid
,man setuid
. Please add more details about how you want to start your service. – Bodo Mar 23 '20 at 13:08