pashage

Yet Another Opinionated Re-engineering of the Unix Password Store
git clone https://git.instinctive.eu/pashage.git
Log | Files | Refs | README | LICENSE

commit 8e82720524ef8bb1272491f11f0e88e0c16e35c9
parent 62f0ea5ad633e7d31a1c2e2b188e2b4bc5953089
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Sat,  9 Nov 2024 08:13:13 +0000

Store root re-encryption is corrected
Diffstat:
Mspec/action_spec.sh | 48++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/pashage.sh | 2+-
2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/spec/action_spec.sh b/spec/action_spec.sh @@ -1665,6 +1665,54 @@ Describe 'Action Functions' The error should equal "$(result)" End + It 'recursively re-encrypts the whole store as /' + result() { + %text:expand + #|$ scm_begin + #|$ do_decrypt ${PREFIX}/root.age + #|$ do_encrypt root-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/root-XXXXXXXXX.age ${PREFIX}/root.age + #|$ scm_add root.age + #|$ do_decrypt ${PREFIX}/subdir/middle.age + #|$ do_encrypt subdir/middle-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/middle-XXXXXXXXX.age ${PREFIX}/subdir/middle.age + #|$ scm_add subdir/middle.age + #|$ do_decrypt ${PREFIX}/subdir/subsub/deep.age + #|$ do_encrypt subdir/subsub/deep-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/subsub/deep-XXXXXXXXX.age ${PREFIX}/subdir/subsub/deep.age + #|$ scm_add subdir/subsub/deep.age + #|$ scm_commit Re-encrypt / + } + When call do_reencrypt / + The status should be success + The output should be blank + The error should equal "$(result)" + End + + It 'recursively re-encrypts the whole store as the empty string' + result() { + %text:expand + #|$ scm_begin + #|$ do_decrypt ${PREFIX}/root.age + #|$ do_encrypt root-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/root-XXXXXXXXX.age ${PREFIX}/root.age + #|$ scm_add root.age + #|$ do_decrypt ${PREFIX}/subdir/middle.age + #|$ do_encrypt subdir/middle-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/middle-XXXXXXXXX.age ${PREFIX}/subdir/middle.age + #|$ scm_add subdir/middle.age + #|$ do_decrypt ${PREFIX}/subdir/subsub/deep.age + #|$ do_encrypt subdir/subsub/deep-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/subsub/deep-XXXXXXXXX.age ${PREFIX}/subdir/subsub/deep.age + #|$ scm_add subdir/subsub/deep.age + #|$ scm_commit Re-encrypt / + } + When call do_reencrypt '' + The status should be success + The output should be blank + The error should equal "$(result)" + End + It 'asks for confirmation before each file' DECISION=interactive YESNO_NEXT=n diff --git a/src/pashage.sh b/src/pashage.sh @@ -847,7 +847,7 @@ do_reencrypt() { # $1: absolute directory path # DECISION: whether to ask before re-encryption do_reencrypt_dir() { - for ENTRY in "$1"/*; do + for ENTRY in "${1%/}"/*; do if [ -d "${ENTRY}" ]; then if ! [ -e "${ENTRY}/.age-recipients" ] \ || [ "${DECISION}" = force ]