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

@ -24,10 +24,7 @@ func tcsetpgrp(fd int, pid int) error {
return errno
}
// 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) {
// open the TTY, we need the file descriptor
tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
if err != nil {