Merge pull request #377 from mrunalp/console_path

Add a constant for the container console path.
This commit is contained in:
Michael Crosby 2015-02-13 15:24:44 -08:00
commit 2990f254f0
2 changed files with 8 additions and 3 deletions

View File

@ -12,6 +12,10 @@ import (
"github.com/docker/libcontainer/label" "github.com/docker/libcontainer/label"
) )
const (
containerConsolePath string = "/dev/console"
)
// NewConsole returns an initalized console that can be used within a container by copying bytes // NewConsole returns an initalized console that can be used within a container by copying bytes
// from the master side to the slave that is attached as the tty for the container's init process. // from the master side to the slave that is attached as the tty for the container's init process.
func NewConsole() (Console, error) { func NewConsole() (Console, error) {
@ -83,7 +87,7 @@ func (c *linuxConsole) mount(rootfs, mountLabel string, uid, gid int) error {
if err := label.SetFileLabel(c.slavePath, mountLabel); err != nil { if err := label.SetFileLabel(c.slavePath, mountLabel); err != nil {
return err return err
} }
dest := filepath.Join(rootfs, "dev/console") dest := filepath.Join(rootfs, containerConsolePath)
f, err := os.Create(dest) f, err := os.Create(dest)
if err != nil && !os.IsExist(err) { if err != nil && !os.IsExist(err) {
return err return err

View File

@ -21,8 +21,9 @@ func (l *linuxUsernsInit) Init() error {
} }
consolePath := l.config.Config.Console consolePath := l.config.Config.Console
if consolePath != "" { if consolePath != "" {
// TODO: why is this hard coded? // We use the containerConsolePath here, because the console has already been
console := newConsoleFromPath("/dev/console") // setup by the side car process for the user namespace scenario.
console := newConsoleFromPath(containerConsolePath)
if err := console.dupStdio(); err != nil { if err := console.dupStdio(); err != nil {
return err return err
} }