summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiaan van Stijn <thaJeztah@users.noreply.github.com>2022-11-11 08:39:09 +0100
committerGitHub <noreply@github.com>2022-11-11 08:39:09 +0100
commit18f8ab6fbd8a55483882f40083731270bc4683e1 (patch)
treee55f039323a4a46c55bdf4dd84c71f2abd65b737
parentbccc3a652bd19320cee05292de88fd8e5ecab2d8 (diff)
parent6fd2d4e77258de3c0eb060a92ccb489351bcd142 (diff)
downloaddocker-18f8ab6fbd8a55483882f40083731270bc4683e1.tar.gz
Merge pull request #44274 from thaJeztah/integration_cli_no_pkg_system
integration(-cli): remove uses of pkg/system.Stat()
-rw-r--r--integration-cli/docker_cli_cp_to_container_unix_test.go9
-rw-r--r--integration-cli/docker_cli_userns_test.go16
-rw-r--r--integration/container/mounts_linux_test.go8
3 files changed, 19 insertions, 14 deletions
diff --git a/integration-cli/docker_cli_cp_to_container_unix_test.go b/integration-cli/docker_cli_cp_to_container_unix_test.go
index 18e50e2c06..68eb4b92f9 100644
--- a/integration-cli/docker_cli_cp_to_container_unix_test.go
+++ b/integration-cli/docker_cli_cp_to_container_unix_test.go
@@ -10,9 +10,9 @@ import (
"path/filepath"
"strconv"
"strings"
+ "syscall"
"testing"
- "github.com/docker/docker/pkg/system"
"gotest.tools/v3/assert"
)
@@ -59,12 +59,13 @@ func (s *DockerCLICpSuite) TestCpCheckDestOwnership(c *testing.T) {
assert.NilError(c, runDockerCp(c, srcPath, dstPath))
- stat, err := system.Stat(filepath.Join(tmpVolDir, "file1"))
+ stat, err := os.Stat(filepath.Join(tmpVolDir, "file1"))
assert.NilError(c, err)
uid, gid, err := getRootUIDGID()
assert.NilError(c, err)
- assert.Equal(c, stat.UID(), uint32(uid), "Copied file not owned by container root UID")
- assert.Equal(c, stat.GID(), uint32(gid), "Copied file not owned by container root GID")
+ fi := stat.Sys().(*syscall.Stat_t)
+ assert.Equal(c, fi.Uid, uint32(uid), "Copied file not owned by container root UID")
+ assert.Equal(c, fi.Gid, uint32(gid), "Copied file not owned by container root GID")
}
func getRootUIDGID() (int, int, error) {
diff --git a/integration-cli/docker_cli_userns_test.go b/integration-cli/docker_cli_userns_test.go
index 5c048c1f33..8fb0b76608 100644
--- a/integration-cli/docker_cli_userns_test.go
+++ b/integration-cli/docker_cli_userns_test.go
@@ -11,10 +11,10 @@ import (
"path/filepath"
"strconv"
"strings"
+ "syscall"
"testing"
"github.com/docker/docker/pkg/stringid"
- "github.com/docker/docker/pkg/system"
"gotest.tools/v3/assert"
)
@@ -53,10 +53,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
assert.Equal(c, uidgid[0], user)
// check that the created directory is owned by remapped uid:gid
- statNotExists, err := system.Stat(tmpDirNotExists)
+ statNotExists, err := os.Stat(tmpDirNotExists)
assert.NilError(c, err)
- assert.Equal(c, statNotExists.UID(), uint32(uid), "Created directory not owned by remapped root UID")
- assert.Equal(c, statNotExists.GID(), uint32(gid), "Created directory not owned by remapped root GID")
+ fi := statNotExists.Sys().(*syscall.Stat_t)
+ assert.Equal(c, fi.Uid, uint32(uid), "Created directory not owned by remapped root UID")
+ assert.Equal(c, fi.Gid, uint32(gid), "Created directory not owned by remapped root GID")
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid)
@@ -73,10 +74,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
assert.NilError(c, err)
// check that the touched file is owned by remapped uid:gid
- stat, err := system.Stat(filepath.Join(tmpDir, "testfile"))
+ stat, err := os.Stat(filepath.Join(tmpDir, "testfile"))
assert.NilError(c, err)
- assert.Equal(c, stat.UID(), uint32(uid), "Touched file not owned by remapped root UID")
- assert.Equal(c, stat.GID(), uint32(gid), "Touched file not owned by remapped root GID")
+ fi = stat.Sys().(*syscall.Stat_t)
+ assert.Equal(c, fi.Uid, uint32(uid), "Touched file not owned by remapped root UID")
+ assert.Equal(c, fi.Gid, uint32(gid), "Touched file not owned by remapped root GID")
// use host usernamespace
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
diff --git a/integration/container/mounts_linux_test.go b/integration/container/mounts_linux_test.go
index 3c7aabda24..07bae777ea 100644
--- a/integration/container/mounts_linux_test.go
+++ b/integration/container/mounts_linux_test.go
@@ -3,7 +3,9 @@ package container // import "github.com/docker/docker/integration/container"
import (
"context"
"fmt"
+ "os"
"path/filepath"
+ "syscall"
"testing"
"time"
@@ -14,7 +16,6 @@ import (
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/container"
- "github.com/docker/docker/pkg/system"
"github.com/moby/sys/mount"
"github.com/moby/sys/mountinfo"
"gotest.tools/v3/assert"
@@ -80,9 +81,10 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
// daemon. In all other volume/bind mount situations we have taken this
// same line--we don't chown host file content.
// See GitHub PR 34224 for details.
- statT, err := system.Stat(tmpNWFileMount)
+ info, err := os.Stat(tmpNWFileMount)
assert.NilError(t, err)
- assert.Check(t, is.Equal(uint32(0), statT.UID()), "bind mounted network file should not change ownership from root")
+ fi := info.Sys().(*syscall.Stat_t)
+ assert.Check(t, is.Equal(fi.Uid, uint32(0)), "bind mounted network file should not change ownership from root")
}
func TestMountDaemonRoot(t *testing.T) {