diff options
author | Adrian Likins <alikins@redhat.com> | 2017-04-18 19:09:02 +0200 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2017-04-18 19:09:02 +0200 |
commit | ae3d7fb29ed3aac413aea05384dd60eacc5f738c (patch) | |
tree | a691173aed946b88b0c9746efab7259a51a63715 /test/integration/targets/vault/runme.sh | |
parent | When become_method is su, self._play_context.prompt is a function. Fixes #23689 (diff) | |
download | ansible-ae3d7fb29ed3aac413aea05384dd60eacc5f738c.tar.xz ansible-ae3d7fb29ed3aac413aea05384dd60eacc5f738c.zip |
Fix vault reading from stdin (avoid realpath() on non-links) (#23583)
* Fix vault reading from stdin (avoid realpath() on non-links)
os.path.realpath() is used to find the target of file paths that
are symlinks so vault operations happen directly on the target.
However, in addition to resolving symlinks, realpath() also returns
a full path. when reading from stdin, vault cli uses '-' as a special
file path so VaultEditor() will replace with stdin.
realpath() was expanding '-' with the CWD to something like
'/home/user/playbooks/-' causing errors like:
ERROR! [Errno 2] No such file or directory: u'/home/user/ansible/-'
Fix is to specialcase '-' to not use realpath()
Fixes #23567
* to_text decrypt output when writing to stdout
Diffstat (limited to 'test/integration/targets/vault/runme.sh')
-rwxr-xr-x | test/integration/targets/vault/runme.sh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/integration/targets/vault/runme.sh b/test/integration/targets/vault/runme.sh index 7fc14d7196..05603ee747 100755 --- a/test/integration/targets/vault/runme.sh +++ b/test/integration/targets/vault/runme.sh @@ -9,6 +9,8 @@ trap 'rm -rf "${MYTMPDIR}"' EXIT TEST_FILE="${MYTMPDIR}/test_file" echo "This is a test file" > "${TEST_FILE}" +TEST_FILE_OUTPUT="${MYTMPDIR}/test_file_output" + # encrypt it ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE}" @@ -28,6 +30,11 @@ ansible-vault view "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FI ansible-vault decrypt "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FILE}" +# reading/writing to/from stdin/stdin (See https://github.com/ansible/ansible/issues/23567) +ansible-vault encrypt "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --output="${TEST_FILE_OUTPUT}" < "${TEST_FILE}" +ansible-vault view "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" - < "${TEST_FILE_OUTPUT}" +ansible-vault decrypt "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --output=- < "${TEST_FILE_OUTPUT}" + ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" "a test string" ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --name "blippy" "a test string names blippy" |