From 5127c4abf921857fde4ae51f566c86028c8c2911 Mon Sep 17 00:00:00 2001 From: Michael Eischer <9106997+MichaelEischer@users.noreply.github.com> Date: Fri, 25 Sep 2026 22:08:18 +0200 Subject: [PATCH] Fix tar extraction errors in sandboxes (#22071) --- internal/test/helpers.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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