diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2023-09-07 21:30:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 21:30:05 +0200 |
commit | 6177888cf6a6b9fba24e3875bc73138e5be2a224 (patch) | |
tree | 18a19ef3de43f9bb6c7843d1b24b8846b6a477c0 /test/integration/targets/ansible-vault/runme.sh | |
parent | Replace ConfigParser.readfp() with read_file() (#81657) (diff) | |
download | ansible-6177888cf6a6b9fba24e3875bc73138e5be2a224.tar.xz ansible-6177888cf6a6b9fba24e3875bc73138e5be2a224.zip |
ansible-vault: Check if the destination is writable (#81660)
* Before performing shredding the original file, check if the
destination file location is writable or not. This will
prevent corruption of original file.
Fixes: #81455
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'test/integration/targets/ansible-vault/runme.sh')
-rwxr-xr-x | test/integration/targets/ansible-vault/runme.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-vault/runme.sh b/test/integration/targets/ansible-vault/runme.sh index 94b8007826..98399ecad3 100755 --- a/test/integration/targets/ansible-vault/runme.sh +++ b/test/integration/targets/ansible-vault/runme.sh @@ -47,6 +47,18 @@ echo $? # view the vault encrypted password file ansible-vault view "$@" --vault-id vault-password encrypted-vault-password +# check if ansible-vault fails when destination is not writable +NOT_WRITABLE_DIR="${MYTMPDIR}/not_writable" +TEST_FILE_EDIT4="${NOT_WRITABLE_DIR}/testfile" +mkdir "${NOT_WRITABLE_DIR}" +touch "${TEST_FILE_EDIT4}" +chmod ugo-w "${NOT_WRITABLE_DIR}" +ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE_EDIT4}" < /dev/null > log 2>&1 && : +grep "not writable" log && : +WRONG_RC=$? +echo "rc was $WRONG_RC (1 is expected)" +[ $WRONG_RC -eq 1 ] + # encrypt with a password from a vault encrypted password file and multiple vault-ids # should fail because we dont know which vault id to use to encrypt with ansible-vault encrypt "$@" --vault-id vault-password --vault-id encrypted-vault-password "${TEST_FILE_ENC_PASSWORD}" && : |