mirror of
https://github.com/restic/restic.git
synced 2026-09-29 23:40:29 +00:00
Fix tar extraction errors in sandboxes (#22071)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user