|
@@ -11,10 +11,10 @@ import (
|
|
"path/filepath"
|
|
"path/filepath"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "syscall"
|
|
"testing"
|
|
"testing"
|
|
|
|
|
|
"github.com/docker/docker/pkg/stringid"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
- "github.com/docker/docker/pkg/system"
|
|
|
|
"gotest.tools/v3/assert"
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -53,10 +53,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
|
|
assert.Equal(c, uidgid[0], user)
|
|
assert.Equal(c, uidgid[0], user)
|
|
|
|
|
|
// check that the created directory is owned by remapped uid:gid
|
|
// 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.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")
|
|
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
|
|
assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid)
|
|
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)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
// check that the touched file is owned by remapped uid:gid
|
|
// 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.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
|
|
// use host usernamespace
|
|
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
|
|
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
|