Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -10,9 +10,9 @@ import ( |
| 10 | 10 |
"path/filepath" |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"strings" |
| 13 |
+ "syscall" |
|
| 13 | 14 |
"testing" |
| 14 | 15 |
|
| 15 |
- "github.com/docker/docker/pkg/system" |
|
| 16 | 16 |
"gotest.tools/v3/assert" |
| 17 | 17 |
) |
| 18 | 18 |
|
| ... | ... |
@@ -59,12 +59,13 @@ func (s *DockerCLICpSuite) TestCpCheckDestOwnership(c *testing.T) {
|
| 59 | 59 |
|
| 60 | 60 |
assert.NilError(c, runDockerCp(c, srcPath, dstPath)) |
| 61 | 61 |
|
| 62 |
- stat, err := system.Stat(filepath.Join(tmpVolDir, "file1")) |
|
| 62 |
+ stat, err := os.Stat(filepath.Join(tmpVolDir, "file1")) |
|
| 63 | 63 |
assert.NilError(c, err) |
| 64 | 64 |
uid, gid, err := getRootUIDGID() |
| 65 | 65 |
assert.NilError(c, err) |
| 66 |
- assert.Equal(c, stat.UID(), uint32(uid), "Copied file not owned by container root UID") |
|
| 67 |
- assert.Equal(c, stat.GID(), uint32(gid), "Copied file not owned by container root GID") |
|
| 66 |
+ fi := stat.Sys().(*syscall.Stat_t) |
|
| 67 |
+ assert.Equal(c, fi.Uid, uint32(uid), "Copied file not owned by container root UID") |
|
| 68 |
+ assert.Equal(c, fi.Gid, uint32(gid), "Copied file not owned by container root GID") |
|
| 68 | 69 |
} |
| 69 | 70 |
|
| 70 | 71 |
func getRootUIDGID() (int, int, error) {
|
| ... | ... |
@@ -11,10 +11,10 @@ import ( |
| 11 | 11 |
"path/filepath" |
| 12 | 12 |
"strconv" |
| 13 | 13 |
"strings" |
| 14 |
+ "syscall" |
|
| 14 | 15 |
"testing" |
| 15 | 16 |
|
| 16 | 17 |
"github.com/docker/docker/pkg/stringid" |
| 17 |
- "github.com/docker/docker/pkg/system" |
|
| 18 | 18 |
"gotest.tools/v3/assert" |
| 19 | 19 |
) |
| 20 | 20 |
|
| ... | ... |
@@ -53,10 +53,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
|
| 53 | 53 |
assert.Equal(c, uidgid[0], user) |
| 54 | 54 |
|
| 55 | 55 |
// check that the created directory is owned by remapped uid:gid |
| 56 |
- statNotExists, err := system.Stat(tmpDirNotExists) |
|
| 56 |
+ statNotExists, err := os.Stat(tmpDirNotExists) |
|
| 57 | 57 |
assert.NilError(c, err) |
| 58 |
- assert.Equal(c, statNotExists.UID(), uint32(uid), "Created directory not owned by remapped root UID") |
|
| 59 |
- assert.Equal(c, statNotExists.GID(), uint32(gid), "Created directory not owned by remapped root GID") |
|
| 58 |
+ fi := statNotExists.Sys().(*syscall.Stat_t) |
|
| 59 |
+ assert.Equal(c, fi.Uid, uint32(uid), "Created directory not owned by remapped root UID") |
|
| 60 |
+ assert.Equal(c, fi.Gid, uint32(gid), "Created directory not owned by remapped root GID") |
|
| 60 | 61 |
|
| 61 | 62 |
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
|
| 62 | 63 |
assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid) |
| ... | ... |
@@ -73,10 +74,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
|
| 73 | 73 |
assert.NilError(c, err) |
| 74 | 74 |
|
| 75 | 75 |
// check that the touched file is owned by remapped uid:gid |
| 76 |
- stat, err := system.Stat(filepath.Join(tmpDir, "testfile")) |
|
| 76 |
+ stat, err := os.Stat(filepath.Join(tmpDir, "testfile")) |
|
| 77 | 77 |
assert.NilError(c, err) |
| 78 |
- assert.Equal(c, stat.UID(), uint32(uid), "Touched file not owned by remapped root UID") |
|
| 79 |
- assert.Equal(c, stat.GID(), uint32(gid), "Touched file not owned by remapped root GID") |
|
| 78 |
+ fi = stat.Sys().(*syscall.Stat_t) |
|
| 79 |
+ assert.Equal(c, fi.Uid, uint32(uid), "Touched file not owned by remapped root UID") |
|
| 80 |
+ assert.Equal(c, fi.Gid, uint32(gid), "Touched file not owned by remapped root GID") |
|
| 80 | 81 |
|
| 81 | 82 |
// use host usernamespace |
| 82 | 83 |
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
|