Bläddra i källkod

Merge pull request #23000 from jstarks/use_image_version_for_console_check

Windows: Use image version, not OS version for TTY fixup
Alexander Morozov 9 år sedan
förälder
incheckning
089166ebe2

+ 2 - 0
daemon/oci_windows.go

@@ -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)
 		return nil, fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err)
 	}
 	}
 
 
+	s.Platform.OSVersion = img.OSVersion
+
 	// In base spec
 	// In base spec
 	s.Hostname = c.FullHostname()
 	s.Hostname = c.FullHostname()
 
 

+ 1 - 1
libcontainerd/client_windows.go

@@ -222,7 +222,7 @@ func (clnt *client) AddProcess(containerID, processFriendlyName string, procToAd
 	iopipe.Stdin = createStdInCloser(stdin, newProcess)
 	iopipe.Stdin = createStdInCloser(stdin, newProcess)
 
 
 	// TEMP: Work around Windows BS/DEL behavior.
 	// 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
 	// Convert io.ReadClosers to io.Readers
 	if stdout != nil {
 	if stdout != nil {

+ 1 - 1
libcontainerd/container_windows.go

@@ -106,7 +106,7 @@ func (ctr *container) start() error {
 	iopipe.Stdin = createStdInCloser(stdin, hcsProcess)
 	iopipe.Stdin = createStdInCloser(stdin, hcsProcess)
 
 
 	// TEMP: Work around Windows BS/DEL behavior.
 	// 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
 	// Convert io.ReadClosers to io.Readers
 	if stdout != nil {
 	if stdout != nil {

+ 13 - 3
libcontainerd/process_windows.go

@@ -2,9 +2,10 @@ package libcontainerd
 
 
 import (
 import (
 	"io"
 	"io"
+	"strconv"
+	"strings"
 
 
 	"github.com/Microsoft/hcsshim"
 	"github.com/Microsoft/hcsshim"
-	"github.com/docker/docker/pkg/system"
 )
 )
 
 
 // process keeps the state for both main container process and exec process.
 // 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
 // fixStdinBackspaceBehavior works around a bug in Windows before build 14350
 // where it interpreted DEL as VK_DELETE instead of as VK_BACK. This replaces
 // where it interpreted DEL as VK_DELETE instead of as VK_BACK. This replaces
 // DEL with BS to work around this.
 // 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
 		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}
 	return &delToBsWriter{w}
 }
 }
 
 

+ 2 - 0
libcontainerd/windowsoci/oci_windows.go

@@ -86,6 +86,8 @@ type Platform struct {
 	OS string `json:"os"`
 	OS string `json:"os"`
 	// Arch is the architecture
 	// Arch is the architecture
 	Arch string `json:"arch"`
 	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.
 // Mount specifies a mount for a container.