Browse code

LCOW: pass command arguments without extra quoting

Signed-off-by: John Starks <jostarks@microsoft.com>

John Starks authored on 2017/06/23 09:15:10
Showing 4 changed files
... ...
@@ -8,7 +8,9 @@ import (
8 8
 
9 9
 func execSetPlatformOpt(c *container.Container, ec *exec.Config, p *libcontainerd.Process) error {
10 10
 	// Process arguments need to be escaped before sending to OCI.
11
-	p.Args = escapeArgs(p.Args)
12
-	p.User.Username = ec.User
11
+	if c.Platform == "windows" {
12
+		p.Args = escapeArgs(p.Args)
13
+		p.User.Username = ec.User
14
+	}
13 15
 	return nil
14 16
 }
... ...
@@ -98,7 +98,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
98 98
 
99 99
 	// In s.Process
100 100
 	s.Process.Args = append([]string{c.Path}, c.Args...)
101
-	if !c.Config.ArgsEscaped {
101
+	if !c.Config.ArgsEscaped && img.OS == "windows" {
102 102
 		s.Process.Args = escapeArgs(s.Process.Args)
103 103
 	}
104 104
 
... ...
@@ -420,7 +420,11 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly
420 420
 
421 421
 	// Configure the environment for the process
422 422
 	createProcessParms.Environment = setupEnvironmentVariables(procToAdd.Env)
423
-	createProcessParms.CommandLine = strings.Join(procToAdd.Args, " ")
423
+	if container.ociSpec.Platform.OS == "windows" {
424
+		createProcessParms.CommandLine = strings.Join(procToAdd.Args, " ")
425
+	} else {
426
+		createProcessParms.CommandArgs = procToAdd.Args
427
+	}
424 428
 	createProcessParms.User = procToAdd.User.Username
425 429
 
426 430
 	logrus.Debugf("libcontainerd: commandLine: %s", createProcessParms.CommandLine)
... ...
@@ -82,7 +82,11 @@ func (ctr *container) start(attachStdio StdioCallback) error {
82 82
 
83 83
 	// Configure the environment for the process
84 84
 	createProcessParms.Environment = setupEnvironmentVariables(ctr.ociSpec.Process.Env)
85
-	createProcessParms.CommandLine = strings.Join(ctr.ociSpec.Process.Args, " ")
85
+	if ctr.ociSpec.Platform.OS == "windows" {
86
+		createProcessParms.CommandLine = strings.Join(ctr.ociSpec.Process.Args, " ")
87
+	} else {
88
+		createProcessParms.CommandArgs = ctr.ociSpec.Process.Args
89
+	}
86 90
 	createProcessParms.User = ctr.ociSpec.Process.User.Username
87 91
 
88 92
 	// LCOW requires the raw OCI spec passed through HCS and onwards to GCS for the utility VM.