From 2bcefbfa98215f912b75f317d413ed861cd94ba5 Mon Sep 17 00:00:00 2001 From: "Trenton D. Adams" Date: Thu, 3 Jun 2021 22:10:29 -0600 Subject: [PATCH] fix gpg decryption bug gpg decryption from a pipe can't happen unless the key has already been cached. Resort to file based decryption with output to stdout. --- changelog.md | 3 +++ components/restore.sh | 9 ++++++++- test/cloud-tar.bats | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 088aab9..22fbba3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +### 2.3.2 +- fix gpg decryption bug + ### 2.3.1 - README update for 2.3.0 diff --git a/components/restore.sh b/components/restore.sh index 989398e..76ee767 100644 --- a/components/restore.sh +++ b/components/restore.sh @@ -14,6 +14,13 @@ function doRestore() { for backup in ${source_folder}/${backup_name}.*.backup*; do echo "restoring ${backup}" - cat "${backup}" | decrypt | tar -C "${destination_folder}" -g /dev/null -xvz + gpg --pinentry-mode cancel --list-packets "${backup}" > /dev/null + if [ $? -eq 0 ]; then + gpg -d -o - "${backup}" | tar -C "${destination_folder}" -g /dev/null -xvz + else + tar -C "${destination_folder}" -g /dev/null -xvzf "${backup}" + fi + + done } \ No newline at end of file diff --git a/test/cloud-tar.bats b/test/cloud-tar.bats index c1a6d83..c345ab9 100644 --- a/test/cloud-tar.bats +++ b/test/cloud-tar.bats @@ -57,7 +57,8 @@ source ./cloud-tar.sh assert [ -f backup/test-backup.0.backupaa ] refute_output --partial "WARNING your backup will not be encrypted, as no gpg recipient was specified" - function listBackup() { cat backup/test-backup.0.backupaa| gpg -d -o - | tar -tvz; } + function listBackup() { gpg -d -o - backup/test-backup.0.backupaa | tar -tvz; } + run listBackup for i in {1..10}; do assert_output --partial "files/file-${i}";