Run Golang as www-data

前端 未结 4 1638
梦毁少年i
梦毁少年i 2021-01-24 21:54

When I run a Node HTTP server app I usually call a custom function

function runAsWWW()
{
 try 
 {
  process.setgid(\'www-data\');
  process.setuid(\'www-data\');         


        
4条回答
  •  粉色の甜心
    2021-01-24 22:08

    No. You can't reliably setuid or setgid in go, because that doesn't work for multithreaded programs.

    You need to start the program as the intended user, either directly, through a supervisor of some sort (e.g. supervisord, runit, monit), or through your init system.

提交回复
热议问题