Best practice to run Linux service as a different user

后端 未结 8 1319
甜味超标
甜味超标 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条回答
  •  时光取名叫无心
    2020-12-04 05:21

    on a CENTOS (Red Hat) virtual machine for svn server: edited /etc/init.d/svnserver to change the pid to something that svn can write:

    pidfile=${PIDFILE-/home/svn/run/svnserve.pid}
    

    and added option --user=svn:

    daemon --pidfile=${pidfile} --user=svn $exec $args
    

    The original pidfile was /var/run/svnserve.pid. The daemon did not start becaseu only root could write there.

     These all work:
    /etc/init.d/svnserve start
    /etc/init.d/svnserve stop
    /etc/init.d/svnserve restart
    

提交回复
热议问题