mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #26994 from Microsoft/jjh/fix26461regression
Windows: Don't set PATH/TERM on exec
This commit is contained in:
commit
1d669d82c1
2 changed files with 21 additions and 5 deletions
|
@ -3,6 +3,7 @@ package daemon
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -123,11 +124,15 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str
|
|||
execConfig.Tty = config.Tty
|
||||
execConfig.Privileged = config.Privileged
|
||||
execConfig.User = config.User
|
||||
execConfig.Env = []string{
|
||||
"PATH=" + system.DefaultPathEnv,
|
||||
}
|
||||
if config.Tty {
|
||||
execConfig.Env = append(execConfig.Env, "TERM=xterm")
|
||||
|
||||
// On Windows, don't default the path, let the platform do it. Also TERM isn't meaningful
|
||||
if runtime.GOOS != "windows" {
|
||||
execConfig.Env = []string{
|
||||
"PATH=" + system.DefaultPathEnv,
|
||||
}
|
||||
if config.Tty {
|
||||
execConfig.Env = append(execConfig.Env, "TERM=xterm")
|
||||
}
|
||||
}
|
||||
execConfig.Env = utils.ReplaceOrAppendEnvValues(execConfig.Env, container.Config.Env)
|
||||
if len(execConfig.User) == 0 {
|
||||
|
|
|
@ -509,3 +509,14 @@ func (s *DockerSuite) TestExecStartFails(c *check.C) {
|
|||
c.Assert(err, checker.NotNil, check.Commentf(out))
|
||||
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`)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue