Best practice to run Linux service as a different user

后端 未结 8 1333
甜味超标
甜味超标 2020-12-04 04:46

Services default to starting as root at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in

8条回答
  •  旧时难觅i
    2020-12-04 05:25

    On Debian we use the start-stop-daemon utility, which handles pid-files, changing the user, putting the daemon into background and much more.

    I'm not familiar with RedHat, but the daemon utility that you are already using (which is defined in /etc/init.d/functions, btw.) is mentioned everywhere as the equivalent to start-stop-daemon, so either it can also change the uid of your program, or the way you do it is already the correct one.

    If you look around the net, there are several ready-made wrappers that you can use. Some may even be already packaged in RedHat. Have a look at daemonize, for example.

提交回复
热议问题