Skip to content

Windows: CMD not honouring arg escaping#22868

Merged
thaJeztah merged 1 commit intomoby:masterfrom
microsoft:jjh/dockerfilecmd
Jul 7, 2016
Merged

Windows: CMD not honouring arg escaping#22868
thaJeztah merged 1 commit intomoby:masterfrom
microsoft:jjh/dockerfilecmd

Conversation

@lowenna
Copy link
Copy Markdown
Member

@lowenna lowenna commented May 20, 2016

Signed-off-by: John Howard jhoward@microsoft.com

Fixes https://github.com/Microsoft/Virtualization-Documentation/issues/266#issuecomment-220093401 when validated in conjunction with #22489.

@darrenstahlmsft There are two things here: This ensures that the builder also sets the argument escaping for CMD (Windows specific), the exact same way it does for RUN. The second is that when merging an image config with a user config, we were not honouring the fact that arguments had been escaped.


b.runConfig.Cmd = strslice.StrSlice(cmdSlice)
// set config as already being escaped, this prevents double escaping on windows
b.runConfig.ArgsEscaped = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the args getting escaped in the JSON case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not and they're not supposed to be.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't they supposed to be? What program are we having trouble running?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON works fine. It's the shell form that has issues. See issue linked to ^^

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you want to set ArgsEscaped=true in the JSON case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but it's a different, albeit related issue. Can you file a new issue?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully grok this PR, but if you'd adding this for CMD, do you need to add it for ENTRYPOINT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me look into that. Gut reaction is no, but if it turns out the answer is yes, I can follow on with a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't need it for Entrypoint then I'm really confused because its has args just like Cmd does.

@jstarks
Copy link
Copy Markdown
Contributor

jstarks commented May 21, 2016

Commit title has a misspelling in it. A spurious u seems to have snuck in.

@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented May 21, 2016

🇬🇧

Comment thread daemon/commit.go
if len(userConf.Entrypoint) == 0 {
if len(userConf.Cmd) == 0 {
userConf.Cmd = imageConf.Cmd
userConf.ArgsEscaped = imageConf.ArgsEscaped
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by the original purpose behind this flag. It seems that by the time we get to daemon.CreateSpec() if the args are not escaped, we escape them - and this is just for windows. Why aren't we just always escaping the args in the first place (on windows) whenever we stash them in the Cmd and EntryPoint arrays - then we don't need to have this flag at all and we can always just blindly copy the data into the spec. I must be missing something.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point yes, this is the right direction to go in and something I'm actively looking at doing in the future - have a proof of concept of that, but it's non trivial unfortunately.

@thaJeztah
Copy link
Copy Markdown
Member

Can we have a test-case for this?

@lowenna lowenna force-pushed the jjh/dockerfilecmd branch from ad9d476 to 2e0ee95 Compare May 21, 2016 18:46
@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented May 21, 2016

Added TestBuildCmdShellArgsEscaped

@lowenna lowenna force-pushed the jjh/dockerfilecmd branch from 2e0ee95 to 1b46809 Compare May 21, 2016 18:50
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, was wondering about a test that tested what went wrong without the change made in this PR (you mentioned things being double escaping on Windows - shouldn't we test for that?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test updated.

@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented May 23, 2016

GH is being slow to update. May 23, 2016

09:53 Pacific Daylight TimeSome users may experience a delay in pushes or other changes appearing on the site.
09:47 Pacific Daylight Time

@lowenna lowenna force-pushed the jjh/dockerfilecmd branch 2 times, most recently from 281387d to 492d016 Compare May 23, 2016 17:22
@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented May 23, 2016

retest this please

@lowenna lowenna force-pushed the jjh/dockerfilecmd branch 2 times, most recently from 4037c22 to 1289fbc Compare May 23, 2016 18:41
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you forgot to remove some debugging code here

@thaJeztah
Copy link
Copy Markdown
Member

LGTM after my nit is addressed

@lowenna lowenna force-pushed the jjh/dockerfilecmd branch from 1289fbc to 808bbed Compare May 24, 2016 16:21
@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented May 24, 2016

Ooops. Fixed this locally, just forgot to push. Updated.

@thaJeztah
Copy link
Copy Markdown
Member

ping @duglin @tiborvass PTAL

@thaJeztah
Copy link
Copy Markdown
Member

ping @jhowardmsft sorry, looks like this needs a rebase now 😢

Signed-off-by: John Howard <jhoward@microsoft.com>
@lowenna lowenna force-pushed the jjh/dockerfilecmd branch from 808bbed to d05d021 Compare June 15, 2016 23:47
@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented Jun 15, 2016

Rebased

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Jun 20, 2016

ping @duglin

@duglin
Copy link
Copy Markdown
Contributor

duglin commented Jun 21, 2016

While I'd prefer that we do the full/real solution, I'll defer to @jhowardmsft's judgement that it should be done in a separate PR. I'm assuming we'd end up removing this extra config param too, right?

LGTM

@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented Jun 21, 2016

Yup. That's the plan

@jessfraz
Copy link
Copy Markdown
Contributor

jessfraz commented Jul 7, 2016

looks good to me

@thaJeztah
Copy link
Copy Markdown
Member

looks like we have 2 LGTM's and all green. Merging

@thaJeztah thaJeztah merged commit 6167a9a into moby:master Jul 7, 2016
@lowenna lowenna deleted the jjh/dockerfilecmd branch July 7, 2016 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants