Revert "libcontainer: Use pivot_root instead of chroot"

This reverts commit 5b5c884cc8266d0c2a56da0bc2df14cc9d5d85e8.

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-03-06 16:32:06 -08:00
parent c0d5c529bb
commit abd1f8da60

View file

@ -5,7 +5,6 @@ package nsinit
import ( import (
"fmt" "fmt"
"github.com/dotcloud/docker/pkg/system" "github.com/dotcloud/docker/pkg/system"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"syscall" "syscall"
@ -51,29 +50,16 @@ func setupNewMountNamespace(rootfs, console string, readonly bool) error {
if err := system.Chdir(rootfs); err != nil { if err := system.Chdir(rootfs); err != nil {
return fmt.Errorf("chdir into %s %s", rootfs, err) return fmt.Errorf("chdir into %s %s", rootfs, err)
} }
if err := system.Mount(rootfs, "/", "", syscall.MS_MOVE, ""); err != nil {
pivotDir, err := ioutil.TempDir(rootfs, ".pivot_root") return fmt.Errorf("mount move %s into / %s", rootfs, err)
if err != nil {
return fmt.Errorf("can't create pivot_root dir %s", pivotDir, err)
} }
if err := system.Pivotroot(rootfs, pivotDir); err != nil { if err := system.Chroot("."); err != nil {
return fmt.Errorf("pivot_root %s", err) return fmt.Errorf("chroot . %s", err)
} }
if err := system.Chdir("/"); err != nil { if err := system.Chdir("/"); err != nil {
return fmt.Errorf("chdir / %s", err) return fmt.Errorf("chdir / %s", err)
} }
// path to pivot dir now changed, update
pivotDir = filepath.Join("/", filepath.Base(pivotDir))
if err := system.Unmount(pivotDir, syscall.MNT_DETACH); err != nil {
return fmt.Errorf("unmount pivot_root dir %s", err)
}
if err := os.Remove(pivotDir); err != nil {
return fmt.Errorf("remove pivot_root dir %s", err)
}
system.Umask(0022) system.Umask(0022)
return nil return nil