diff --git a/internal/test/helpers.go b/internal/test/helpers.go index 019c5cb6c..f53062a69 100644 --- a/internal/test/helpers.go +++ b/internal/test/helpers.go @@ -10,6 +10,7 @@ import ( "os/exec" "path/filepath" "reflect" + "runtime" "testing" "github.com/restic/restic/internal/errors" @@ -122,7 +123,13 @@ func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) { rd = input } - cmd := exec.Command("tar", "xf", "-") + cmdLine := []string{"tar", "xf", "-"} + // Do not restore ownership from the archive. It is not necessary for the tests, + // but can cause problems in sandboxed environments. + if runtime.GOOS != "windows" { + cmdLine = append(cmdLine, "--no-same-owner") + } + cmd := exec.Command(cmdLine[0], cmdLine[1:]...) cmd.Dir = outputDir cmd.Stdin = rd