diff --git a/pkg/chrootarchive/archive_test.go b/pkg/chrootarchive/archive_test.go index 5666be2970..755e7daad9 100644 --- a/pkg/chrootarchive/archive_test.go +++ b/pkg/chrootarchive/archive_test.go @@ -15,7 +15,6 @@ import ( "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/reexec" - "github.com/docker/docker/pkg/system" "gotest.tools/v3/skip" ) @@ -45,7 +44,7 @@ func TestChrootTarUntar(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(src, "toto"), []byte("hello toto"), 0644); err != nil { @@ -59,7 +58,7 @@ func TestChrootTarUntar(t *testing.T) { t.Fatal(err) } dest := filepath.Join(tmpdir, "dest") - if err := system.MkdirAll(dest, 0700); err != nil { + if err := os.Mkdir(dest, 0o700); err != nil { t.Fatal(err) } if err := Untar(stream, dest, &archive.TarOptions{ExcludePatterns: []string{"lolo"}}); err != nil { @@ -73,7 +72,7 @@ func TestChrootUntarWithHugeExcludesList(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(src, "toto"), []byte("hello toto"), 0644); err != nil { @@ -84,7 +83,7 @@ func TestChrootUntarWithHugeExcludesList(t *testing.T) { t.Fatal(err) } dest := filepath.Join(tmpdir, "dest") - if err := system.MkdirAll(dest, 0700); err != nil { + if err := os.Mkdir(dest, 0o700); err != nil { t.Fatal(err) } options := &archive.TarOptions{} @@ -165,7 +164,7 @@ func TestChrootTarUntarWithSymlink(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if _, err := prepareSourceDirectory(10, src, false); err != nil { @@ -185,7 +184,7 @@ func TestChrootCopyWithTar(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if _, err := prepareSourceDirectory(10, src, true); err != nil { @@ -228,7 +227,7 @@ func TestChrootCopyFileWithTar(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if _, err := prepareSourceDirectory(10, src, true); err != nil { @@ -269,7 +268,7 @@ func TestChrootUntarPath(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if _, err := prepareSourceDirectory(10, src, false); err != nil { @@ -327,7 +326,7 @@ func TestChrootUntarEmptyArchiveFromSlowReader(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() dest := filepath.Join(tmpdir, "dest") - if err := system.MkdirAll(dest, 0700); err != nil { + if err := os.Mkdir(dest, 0o700); err != nil { t.Fatal(err) } stream := &slowEmptyTarReader{size: 10240, chunkSize: 1024} @@ -340,7 +339,7 @@ func TestChrootApplyEmptyArchiveFromSlowReader(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() dest := filepath.Join(tmpdir, "dest") - if err := system.MkdirAll(dest, 0700); err != nil { + if err := os.Mkdir(dest, 0o700); err != nil { t.Fatal(err) } stream := &slowEmptyTarReader{size: 10240, chunkSize: 1024} @@ -353,7 +352,7 @@ func TestChrootApplyDotDotFile(t *testing.T) { skip.If(t, os.Getuid() != 0, "skipping test that requires root") tmpdir := t.TempDir() src := filepath.Join(tmpdir, "src") - if err := system.MkdirAll(src, 0700); err != nil { + if err := os.Mkdir(src, 0o700); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(src, "..gitme"), []byte(""), 0644); err != nil { @@ -364,7 +363,7 @@ func TestChrootApplyDotDotFile(t *testing.T) { t.Fatal(err) } dest := filepath.Join(tmpdir, "dest") - if err := system.MkdirAll(dest, 0700); err != nil { + if err := os.Mkdir(dest, 0o700); err != nil { t.Fatal(err) } if _, err := ApplyLayer(dest, stream); err != nil { diff --git a/pkg/chrootarchive/archive_unix_test.go b/pkg/chrootarchive/archive_unix_test.go index 8349b4f02c..3cac35384c 100644 --- a/pkg/chrootarchive/archive_unix_test.go +++ b/pkg/chrootarchive/archive_unix_test.go @@ -29,7 +29,7 @@ func TestUntarWithMaliciousSymlinks(t *testing.T) { root := filepath.Join(dir, "root") - err := os.MkdirAll(root, 0o755) + err := os.Mkdir(root, 0o755) assert.NilError(t, err) // Add a file into a directory above root @@ -42,7 +42,7 @@ func TestUntarWithMaliciousSymlinks(t *testing.T) { // Before this change, the copy would overwrite the "host" content. // With this change it should not. data := filepath.Join(dir, "data") - err = os.MkdirAll(data, 0755) + err = os.Mkdir(data, 0o755) assert.NilError(t, err) err = os.WriteFile(filepath.Join(data, "local-file"), []byte("pwn3d"), 0644) assert.NilError(t, err) @@ -92,7 +92,7 @@ func TestTarWithMaliciousSymlinks(t *testing.T) { root := filepath.Join(dir, "root") - err = os.MkdirAll(root, 0755) + err = os.Mkdir(root, 0o755) assert.NilError(t, err) hostFileData := []byte("I am a host file") @@ -107,7 +107,7 @@ func TestTarWithMaliciousSymlinks(t *testing.T) { assert.NilError(t, err) data := filepath.Join(dir, "data") - err = os.MkdirAll(data, 0755) + err = os.Mkdir(data, 0o755) assert.NilError(t, err) type testCase struct {