From d52d24dd801f3ffe1b894226b8dba613de59bd87 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 1 Apr 2014 00:28:44 +0000 Subject: [PATCH 1/2] remove setupDev from libcontainer Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) --- pkg/libcontainer/nsinit/mount.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/pkg/libcontainer/nsinit/mount.go b/pkg/libcontainer/nsinit/mount.go index 796143c68e..59f4a0e0d9 100644 --- a/pkg/libcontainer/nsinit/mount.go +++ b/pkg/libcontainer/nsinit/mount.go @@ -62,9 +62,6 @@ func setupNewMountNamespace(rootfs string, bindMounts []libcontainer.Mount, cons } // In non-privileged mode, this fails. Discard the error. setupLoopbackDevices(rootfs) - if err := setupDev(rootfs); err != nil { - return err - } if err := setupPtmx(rootfs, console, mountLabel); err != nil { return err } @@ -172,30 +169,6 @@ func copyDevNode(rootfs, node string) error { return nil } -// setupDev symlinks the current processes pipes into the -// appropriate destination on the containers rootfs -func setupDev(rootfs string) error { - for _, link := range []struct { - from string - to string - }{ - {"/proc/kcore", "/dev/core"}, - {"/proc/self/fd", "/dev/fd"}, - {"/proc/self/fd/0", "/dev/stdin"}, - {"/proc/self/fd/1", "/dev/stdout"}, - {"/proc/self/fd/2", "/dev/stderr"}, - } { - dest := filepath.Join(rootfs, link.to) - if err := os.Remove(dest); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("remove %s %s", dest, err) - } - if err := os.Symlink(link.from, dest); err != nil { - return fmt.Errorf("symlink %s %s", dest, err) - } - } - return nil -} - // setupConsole ensures that the container has a proper /dev/console setup func setupConsole(rootfs, console string, mountLabel string) error { oldMask := system.Umask(0000) From dcf2b72f5b6732a4b9b1897cb2b3f7019e3d547e Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 1 Apr 2014 21:07:40 +0000 Subject: [PATCH 2/2] add test Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) --- integration-cli/docker_cli_diff_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/integration-cli/docker_cli_diff_test.go b/integration-cli/docker_cli_diff_test.go index 5f8ba74161..0ae9cca38d 100644 --- a/integration-cli/docker_cli_diff_test.go +++ b/integration-cli/docker_cli_diff_test.go @@ -64,3 +64,28 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) { logDone("diff - check if ignored files show up in diff") } + +func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) { + runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep 0") + cid, _, err := runCommandWithOutput(runCmd) + errorOut(err, t, fmt.Sprintf("%s", err)) + cleanCID := stripTrailingCharacters(cid) + + diffCmd := exec.Command(dockerBinary, "diff", cleanCID) + out, _, err := runCommandWithOutput(diffCmd) + errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err)) + go deleteContainer(cleanCID) + + expected := map[string]bool{ + "C /dev": true, + "A /dev/full": true, // busybox + "C /dev/ptmx": true, // libcontainer + "A /dev/kmsg": true, // lxc + } + + for _, line := range strings.Split(out, "\n") { + if line != "" && !expected[line] { + t.Errorf("'%s' is shown in the diff but shouldn't", line) + } + } +}