Fix tar extraction errors in sandboxes (#22071)

This commit is contained in:
Michael Eischer
2026-09-25 22:08:18 +02:00
committed by GitHub
parent 8e917cf0bd
commit 5127c4abf9
+8 -1
View File
@@ -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