libcontainer: Don't create a device node on /dev/console to bind mount on
There is no need for this, the device node by itself doesn't work, since its not on a devpts fs, and we can just a regular file to bind mount over. Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
parent
a193d05209
commit
95a61f16dc
1 changed files with 12 additions and 15 deletions
|
@ -17,29 +17,26 @@ func Setup(rootfs, consolePath, mountLabel string) error {
|
||||||
oldMask := system.Umask(0000)
|
oldMask := system.Umask(0000)
|
||||||
defer system.Umask(oldMask)
|
defer system.Umask(oldMask)
|
||||||
|
|
||||||
stat, err := os.Stat(consolePath)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("stat console %s %s", consolePath, err)
|
|
||||||
}
|
|
||||||
var (
|
|
||||||
st = stat.Sys().(*syscall.Stat_t)
|
|
||||||
dest = filepath.Join(rootfs, "dev/console")
|
|
||||||
)
|
|
||||||
if err := os.Remove(dest); err != nil && !os.IsNotExist(err) {
|
|
||||||
return fmt.Errorf("remove %s %s", dest, err)
|
|
||||||
}
|
|
||||||
if err := os.Chmod(consolePath, 0600); err != nil {
|
if err := os.Chmod(consolePath, 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.Chown(consolePath, 0, 0); err != nil {
|
if err := os.Chown(consolePath, 0, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := system.Mknod(dest, (st.Mode&^07777)|0600, int(st.Rdev)); err != nil {
|
|
||||||
return fmt.Errorf("mknod %s %s", dest, err)
|
|
||||||
}
|
|
||||||
if err := label.SetFileLabel(consolePath, mountLabel); err != nil {
|
if err := label.SetFileLabel(consolePath, mountLabel); err != nil {
|
||||||
return fmt.Errorf("set file label %s %s", dest, err)
|
return fmt.Errorf("set file label %s %s", consolePath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dest := filepath.Join(rootfs, "dev/console")
|
||||||
|
|
||||||
|
f, err := os.Create(dest)
|
||||||
|
if err != nil && !os.IsExist(err) {
|
||||||
|
return fmt.Errorf("create %s %s", dest, err)
|
||||||
|
}
|
||||||
|
if f != nil {
|
||||||
|
f.Close()
|
||||||
|
}
|
||||||
|
|
||||||
if err := system.Mount(consolePath, dest, "bind", syscall.MS_BIND, ""); err != nil {
|
if err := system.Mount(consolePath, dest, "bind", syscall.MS_BIND, ""); err != nil {
|
||||||
return fmt.Errorf("bind %s to %s %s", consolePath, dest, err)
|
return fmt.Errorf("bind %s to %s %s", consolePath, dest, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue