New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning to mac runas docs about escaping characters #48981

Merged
merged 3 commits into from Aug 8, 2018

Conversation

Projects
None yet
3 participants
@Ch3LL
Contributor

Ch3LL commented Aug 7, 2018

What does this PR do?

currently the test integration.modules.test_cmdmod.CMDModuleTest.test_quotes_runas is failing with error:

Traceback (most recent call last):
  File "/testing/tests/integration/modules/test_cmdmod.py", line 276, in test_quotes_runas
    self.assertEqual(result, expected_result)
AssertionError: u'SELECT * FROM foo WHERE bar=baz' != u'SELECT * FROM foo WHERE bar="baz"'
- SELECT * FROM foo WHERE bar=baz
+ SELECT * FROM foo WHERE bar="baz"
?                             +   +

This is due to this fix recently added: #47212

It changed the call to su -l <user> -c "<cmd>"

As you can see below quotes are handled differently when calling from su

without su:

jk-sierra-base:testing root# echo '"baz"'
"baz"
jk-sierra-base:testing root# su -l root -c "echo '"baz"'"
baz

as you can see when using su it does not include the quotes only when you escape the quotes like below:

jk-sierra-base:testing root# su -l root -c "echo '\"baz\"'"
"baz"

I tried using _cmd_quote but that only created failures so I do not see a good way to fix this other then documenting that when you use the cmd module on macosx with runas you need to escape quotes. If anyone has a better approach I'm up for approaching it differently.

fyi @weswhet

Ch3LL added some commits Aug 7, 2018

@Ch3LL Ch3LL requested a review from terminalmage Aug 7, 2018

@rallytime rallytime merged commit 4590494 into saltstack:2018.3 Aug 8, 2018

3 of 8 checks passed

continuous-integration/jenkins/pr-merge This commit cannot be built
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has failed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has failed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has failed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has failed
Details
WIP ready for review
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment