Sanitize environment before starting backend processes (rclone, ssh)

The restic security model includes full trust of the local machine, so
this should not fix any actual security problems, but it's better to be
safe than sorry.

Fixes #2192.
This commit is contained in:
greatroar
2020-10-03 13:27:23 +02:00
parent 4875f7b659
commit 11fbaaae9a
5 changed files with 67 additions and 12 deletions

View File

@@ -7,10 +7,7 @@ import (
"github.com/restic/restic/internal/errors"
)
// StartForeground runs cmd in the foreground, by temporarily switching to the
// new process group created for cmd. The returned function `bg` switches back
// to the previous process group.
func StartForeground(cmd *exec.Cmd) (bg func() error, err error) {
func startForeground(cmd *exec.Cmd) (bg func() error, err error) {
// run the command in it's own process group so that SIGINT
// is not sent to it.
cmd.SysProcAttr = &syscall.SysProcAttr{