Merge pull request #23000 from jstarks/use_image_version_for_console_check

Windows: Use image version, not OS version for TTY fixup
This commit is contained in:
Alexander Morozov 2016-05-25 17:40:56 -07:00
commit 089166ebe2
5 changed files with 19 additions and 5 deletions

View File

@ -34,6 +34,8 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
return nil, fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err)
}
s.Platform.OSVersion = img.OSVersion
// In base spec
s.Hostname = c.FullHostname()

View File

@ -222,7 +222,7 @@ func (clnt *client) AddProcess(containerID, processFriendlyName string, procToAd
iopipe.Stdin = createStdInCloser(stdin, newProcess)
// TEMP: Work around Windows BS/DEL behavior.
iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, procToAdd.Terminal)
iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, container.ociSpec.Platform.OSVersion, procToAdd.Terminal)
// Convert io.ReadClosers to io.Readers
if stdout != nil {

View File

@ -106,7 +106,7 @@ func (ctr *container) start() error {
iopipe.Stdin = createStdInCloser(stdin, hcsProcess)
// TEMP: Work around Windows BS/DEL behavior.
iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, ctr.ociSpec.Process.Terminal)
iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, ctr.ociSpec.Platform.OSVersion, ctr.ociSpec.Process.Terminal)
// Convert io.ReadClosers to io.Readers
if stdout != nil {

View File

@ -2,9 +2,10 @@ package libcontainerd
import (
"io"
"strconv"
"strings"
"github.com/Microsoft/hcsshim"
"github.com/docker/docker/pkg/system"
)
// process keeps the state for both main container process and exec process.
@ -33,10 +34,19 @@ func openReaderFromPipe(p io.ReadCloser) io.Reader {
// fixStdinBackspaceBehavior works around a bug in Windows before build 14350
// where it interpreted DEL as VK_DELETE instead of as VK_BACK. This replaces
// DEL with BS to work around this.
func fixStdinBackspaceBehavior(w io.WriteCloser, tty bool) io.WriteCloser {
if !tty || system.GetOSVersion().Build >= 14350 {
func fixStdinBackspaceBehavior(w io.WriteCloser, osversion string, tty bool) io.WriteCloser {
if !tty {
return w
}
v := strings.Split(osversion, ".")
if len(v) < 3 {
return w
}
if build, err := strconv.Atoi(v[2]); err != nil || build >= 14350 {
return w
}
return &delToBsWriter{w}
}

View File

@ -86,6 +86,8 @@ type Platform struct {
OS string `json:"os"`
// Arch is the architecture
Arch string `json:"arch"`
// OSVersion is the version of the operating system.
OSVersion string `json:"os.version,omitempty"`
}
// Mount specifies a mount for a container.