Do not reencrypt symbolic links

Aldis Berjoza aldis at berjoza.lv
Wed Aug 8 22:27:06 CEST 2018


Hello!

I've attched patch that skips symbolic links during reencryption,
otherwise symbolic links are replaced with regular files.

--
Aldis Berjoza
https://aldis.berjoza.lv
-------------- next part --------------
From 530cc646b21b7c55fab1a2ee36bb22dee68ff787 Mon Sep 17 00:00:00 2001
From: Aldis Berjoza <aldis at berjoza.lv>
Date: Wed, 8 Aug 2018 22:23:23 +0300
Subject: [PATCH] Fix: Do not reencrypt symbolic links

---
 src/password-store.sh       | 1 +
 tests/t0300-reencryption.sh | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/src/password-store.sh b/src/password-store.sh
index 7264ffc..8eeaf85 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -108,6 +108,7 @@ reencrypt_path() {
 	local prev_gpg_recipients="" gpg_keys="" current_keys="" index passfile
 	local groups="$($GPG $PASSWORD_STORE_GPG_OPTS --list-config --with-colons | grep "^cfg:group:.*")"
 	while read -r -d "" passfile; do
+		[[ -L "$passfile" ]] && continue
 		local passfile_dir="${passfile%/*}"
 		passfile_dir="${passfile_dir#$PREFIX}"
 		passfile_dir="${passfile_dir#/}"
diff --git a/tests/t0300-reencryption.sh b/tests/t0300-reencryption.sh
index 6d15364..6385cd6 100755
--- a/tests/t0300-reencryption.sh
+++ b/tests/t0300-reencryption.sh
@@ -87,6 +87,15 @@ test_expect_success 'Reencryption subfolder multiple keys, move, deinit' '
 	[[ $(canonicalize_gpg_keys $KEY3 $KEY4 $KEY2) == "$(gpg_keys_from_encrypted_file "$PASSWORD_STORE_DIR/anotherfolder2/anotherfolder/cred1.gpg")" ]]
 '
 
+test_expect_success 'Reencryption skips links' '
+	ln -s "$PASSWORD_STORE_DIR/folder/cred1.gpg" "$PASSWORD_STORE_DIR/folder/linked_cred.gpg" &&
+	[[ -L "$PASSWORD_STORE_DIR/folder/linked_cred.gpg" ]] &&
+	git add "$PASSWORD_STORE_DIR/folder/linked_cred.gpg" &&
+	git commit "$PASSWORD_STORE_DIR/folder/linked_cred.gpg" -m "Added linked cred" &&
+	"$PASS" init -p folder $KEY3 &&
+	[[ -L "$PASSWORD_STORE_DIR/folder/linked_cred.gpg" ]]
+'
+
 #TODO: test with more varieties of move and copy!
 
 test_expect_success 'Password lived through all transformations' '
-- 
2.18.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 313 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20180808/ca2348f7/attachment.asc>


More information about the Password-Store mailing list