-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump Restic's version to 0.11+pull 3306
SHA1: fae4be8424186659fafba32c64b0cb5b0e2e376c From restic/restic#3006
- Loading branch information
Showing
38 changed files
with
720 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package backend | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
// 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. | ||
// | ||
// The command's environment has all RESTIC_* variables removed. | ||
func StartForeground(cmd *exec.Cmd) (bg func() error, err error) { | ||
env := os.Environ() // Returns a copy that we can modify. | ||
|
||
cmd.Env = env[:0] | ||
for _, kv := range env { | ||
if strings.HasPrefix(kv, "RESTIC_") { | ||
continue | ||
} | ||
cmd.Env = append(cmd.Env, kv) | ||
} | ||
|
||
return startForeground(cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// +build !windows | ||
|
||
package backend_test | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/rubiojr/rapi/backend" | ||
rtest "github.com/rubiojr/rapi/internal/test" | ||
) | ||
|
||
func TestForeground(t *testing.T) { | ||
err := os.Setenv("RESTIC_PASSWORD", "supersecret") | ||
rtest.OK(t, err) | ||
|
||
cmd := exec.Command("env") | ||
stdout, err := cmd.StdoutPipe() | ||
rtest.OK(t, err) | ||
|
||
bg, err := backend.StartForeground(cmd) | ||
rtest.OK(t, err) | ||
defer cmd.Wait() | ||
|
||
err = bg() | ||
rtest.OK(t, err) | ||
|
||
sc := bufio.NewScanner(stdout) | ||
for sc.Scan() { | ||
if strings.HasPrefix(sc.Text(), "RESTIC_PASSWORD=") { | ||
t.Error("subprocess got to see the password") | ||
} | ||
} | ||
rtest.OK(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.