diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index eab2dc68..512093f1 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -188,7 +188,7 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error { check := flag.Bool("check", false, "check the configuration file and exit") configFile := flag.String("config", DefaultConfigFileName, "Path to the configuration file") username := flag.String("username", "", "After binding to the port user privileges are dropped") - child := flag.Bool("start-child", false, "Invokes program as a child process") + child := flag.Bool("child", false, "Invokes program as a child process") flag.Parse() diff --git a/dnscrypt-proxy/privilege_free.go b/dnscrypt-proxy/privilege_others.go similarity index 84% rename from dnscrypt-proxy/privilege_free.go rename to dnscrypt-proxy/privilege_others.go index 4f29db1b..ad6bb344 100644 --- a/dnscrypt-proxy/privilege_free.go +++ b/dnscrypt-proxy/privilege_others.go @@ -9,6 +9,7 @@ import ( "path/filepath" "strconv" "syscall" + "github.com/jedisct1/dlog" ) @@ -27,11 +28,11 @@ func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) { if err != nil { dlog.Fatal(err) } - exec_path, err := exec.LookPath(args[0]) + execPath, err := exec.LookPath(args[0]) if err != nil { dlog.Fatal(err) } - path, err := filepath.Abs(exec_path) + path, err := filepath.Abs(execPath) if err != nil { dlog.Fatal(err) } @@ -40,7 +41,7 @@ func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) { copy(args[0:], args[0+1:]) args[len(args)-1] = "" args = args[:len(args)-1] - args = append(args, "-start-child") + args = append(args, "-child") cmd := exec.Command(path, args...) cmd.Stdout = os.Stdout @@ -48,8 +49,9 @@ func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) { cmd.ExtraFiles = fds cmd.SysProcAttr = &syscall.SysProcAttr{} cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)} + cmd.SysProcAttr.Setsid = true dlog.Notice("Dropping privileges") - if err := cmd.Start(); err != nil { + if err := cmd.Run(); err != nil { dlog.Fatal(err) } os.Exit(0)