From 77085907a44039fe1cf9fe24d9c7675aa53d2f9b Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 13 Feb 2015 18:15:58 -0500 Subject: [PATCH] Add a constant for the container console path. Signed-off-by: Mrunal Patel --- linux_console.go | 6 +++++- linux_userns_init.go | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/linux_console.go b/linux_console.go index 5cb5f713..60de3ee9 100644 --- a/linux_console.go +++ b/linux_console.go @@ -12,6 +12,10 @@ import ( "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 // from the master side to the slave that is attached as the tty for the container's init process. 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 { return err } - dest := filepath.Join(rootfs, "dev/console") + dest := filepath.Join(rootfs, containerConsolePath) f, err := os.Create(dest) if err != nil && !os.IsExist(err) { return err diff --git a/linux_userns_init.go b/linux_userns_init.go index bd7e402c..d07668cd 100644 --- a/linux_userns_init.go +++ b/linux_userns_init.go @@ -21,8 +21,9 @@ func (l *linuxUsernsInit) Init() error { } consolePath := l.config.Config.Console if consolePath != "" { - // TODO: why is this hard coded? - console := newConsoleFromPath("/dev/console") + // We use the containerConsolePath here, because the console has already been + // setup by the side car process for the user namespace scenario. + console := newConsoleFromPath(containerConsolePath) if err := console.dupStdio(); err != nil { return err }