mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-21 03:15:47 +01:00
Automatically restart after unexpected errors
This commit is contained in:
parent
f9b6994fd2
commit
73a43b31b9
@ -9,6 +9,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/jedisct1/dlog"
|
"github.com/jedisct1/dlog"
|
||||||
)
|
)
|
||||||
@ -40,15 +41,18 @@ func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) {
|
|||||||
args = args[1:]
|
args = args[1:]
|
||||||
args = append(args, "-child")
|
args = append(args, "-child")
|
||||||
|
|
||||||
cmd := exec.Command(path, args...)
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.ExtraFiles = fds
|
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
||||||
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
|
||||||
dlog.Notice("Dropping privileges")
|
dlog.Notice("Dropping privileges")
|
||||||
if err := cmd.Run(); err != nil {
|
for {
|
||||||
dlog.Fatal(err)
|
cmd := exec.Command(path, args...)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
cmd.ExtraFiles = fds
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
|
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
||||||
|
if cmd.Run() == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user