Merge ~powersj/cloud-init:cii-strings into cloud-init:master
| Status: | Merged |
|---|---|
| Merged at revision: | 1ac4bc2a4758d330bb94cd1b2391121cf461ff6a |
| Proposed branch: | ~powersj/cloud-init:cii-strings |
| Merge into: | cloud-init:master |
| Diff against target: |
135 lines (+22/-13) 4 files modified
tests/cloud_tests/bddeb.py (+1/-2) tests/cloud_tests/instances/base.py (+6/-4) tests/cloud_tests/instances/lxd.py (+9/-1) tests/cloud_tests/setup_image.py (+6/-6) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Server Team CI bot | continuous-integration | Approve on 2017-09-13 | |
| cloud-init commiters | 2017-09-11 | Pending | |
|
Review via email:
|
|||
Commit Message
tests: execute: support command as string
If a string is passed to execute, then invoke 'bash', '-c',
'string'. That allows the less verbose execution of simple
commands:
image.execute("ls /run")
compared to the more explicit but longer winded:
image.
If 'env' was ever modified in execute or a method that it called,
then the next invocation's default value would be changed. Instead
use None and then set to a new empty dict in the method.
| Scott Moser (smoser) wrote : | # |
I'd like 2 things changed
a.) do not use /bin/bash or require it by (Instance/
That is not python's default shell, unless /bin/sh == /bin/bash on the system.
b.) lets only fix strings where we were already using sh (via sh -c).
throwing stuff to sh just allows for errors and unexpected behavior.
I realize this is a contrived example, but its the kind of unexpected results you can get when you hand things off to shell interpretation and are not careful about quoting
## pretend tmp=$(mktemp -d) happens to return the literal name '/tmp/foo?'
## simulate this behavior by the 'tmp=; mkdir -p'
$ touch /tmp/foo1 /tmp/foo2
$ tmp=/tmp/foo?; mkdir -p "/tmp/foo?"
# ls /tmp/
foo1 foo2 foo?
# rm -Rvf $tmp
removed `/tmp/foo1'
removed `/tmp/foo2'
removed directory: `/tmp/foo?'
## YIKES!
I'll give you a diff or a MP with the changes i'd like.
| Scott Moser (smoser) wrote : | # |
Note above, 'mktemp -d' is probably not going to give you 'foo?'. However, nothing that i'm aware of promises that it's returned filenames will not have any characters that may be "special" to /bin/sh (or /usr/bin/perl or /usr/bin/python or gcc).
PASSED: Continuous integration, rev:2be9c0f1418
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/


PASSED: Continuous integration, rev:2f2717cc364 a7ab2d7ff129f5b 862643ab24af3f /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 283/
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 283/rebuild
https:/