commit: 9c41e075519308fcc5448489c09e1e74c6e64ba8
parent 781250ac786ea489e79dcf8f37f42522be8a6b0e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 24 May 2020 17:27:27 +0200
pass2secret: Fix syntax, TOTP and presence check
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/pass2secret b/pass2secret
@@ -12,7 +12,7 @@ set -e
touch "$SECRET_FILE"
chmod 700 "$SECRET_FILE"
-printf "Passphrase: "
+printf "secret(1) passphrase: "
read -r passphrase
echo
@@ -27,19 +27,20 @@ cd "$workdir"
) | while read -r entry
do
( pass show "$entry" && echo ) > "$SECRET_FILE"
- if [ ! -f "$workdir/$entry" ]
+ if [ ! -f "$workdir/$entry.reop" ]
then echo "$passphrase" | secret write "$entry"
+ else echo "following entry exists, ignoring: $entry"
fi
- if [ ! -f "$workdir/$entry.oath" ] && grep "^otpauth" "$SECRET_FILE"
+ if [ ! -f "$workdir/$entry.oath.reop" ] && grep -q "^otpauth://" "$SECRET_FILE"
then
- pass show "$entry" | sed \
- -e 's;^otpauth://totp/totp-secret?secret=q;;' \
+ pass show "$entry" \
+ | grep "^optauth://" \
+ | sed \
+ -e 's;^otpauth://totp/totp-secret?secret=;;' \
-e 's;^;--base32 ;' > "$SECRET_FILE"
echo "$passphrase" | secret write "${entry}.oath"
- else
- echo "following entry exists, ignoring: $workdir/$entry"
fi
done