1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Windows: Don't set PATH/TERM on exec

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-09-28 13:34:47 -07:00
parent 601004e1a7
commit e880bbc48b
2 changed files with 21 additions and 5 deletions

View file

@ -3,6 +3,7 @@ package daemon
import ( import (
"fmt" "fmt"
"io" "io"
"runtime"
"strings" "strings"
"time" "time"
@ -123,12 +124,16 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str
execConfig.Tty = config.Tty execConfig.Tty = config.Tty
execConfig.Privileged = config.Privileged execConfig.Privileged = config.Privileged
execConfig.User = config.User execConfig.User = config.User
// On Windows, don't default the path, let the platform do it. Also TERM isn't meaningful
if runtime.GOOS != "windows" {
execConfig.Env = []string{ execConfig.Env = []string{
"PATH=" + system.DefaultPathEnv, "PATH=" + system.DefaultPathEnv,
} }
if config.Tty { if config.Tty {
execConfig.Env = append(execConfig.Env, "TERM=xterm") execConfig.Env = append(execConfig.Env, "TERM=xterm")
} }
}
execConfig.Env = utils.ReplaceOrAppendEnvValues(execConfig.Env, container.Config.Env) execConfig.Env = utils.ReplaceOrAppendEnvValues(execConfig.Env, container.Config.Env)
if len(execConfig.User) == 0 { if len(execConfig.User) == 0 {
execConfig.User = container.Config.User execConfig.User = container.Config.User

View file

@ -509,3 +509,14 @@ func (s *DockerSuite) TestExecStartFails(c *check.C) {
c.Assert(err, checker.NotNil, check.Commentf(out)) c.Assert(err, checker.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "executable file not found") c.Assert(out, checker.Contains, "executable file not found")
} }
// Fix regression in https://github.com/docker/docker/pull/26461#issuecomment-250287297
func (s *DockerSuite) TestExecWindowsPathNotWiped(c *check.C) {
testRequires(c, DaemonIsWindows)
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", minimalBaseImage(), "powershell", "start-sleep", "60")
c.Assert(waitRun(strings.TrimSpace(out)), check.IsNil)
out, _ = dockerCmd(c, "exec", "testing", "powershell", "write-host", "$env:PATH")
out = strings.ToLower(strings.Trim(out, "\r\n"))
c.Assert(out, checker.Contains, `windowspowershell\v1.0`)
}