summaryrefslogtreecommitdiff
path: root/passwort-tresor.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-08-19 13:01:34 +0200
committerErich Eckner <git@eckner.net>2016-08-19 13:01:34 +0200
commitec9e441825b0a4b1780f9f3b416e491c4012b5dd (patch)
tree8754bb17c4d6624c24a9e469eac5fa4ddb84ce51 /passwort-tresor.in
parenteeb39874db4d83249aa3a6be7ef7e02c3bc63a81 (diff)
downloadpasswort-tresor-ec9e441825b0a4b1780f9f3b416e491c4012b5dd.tar.xz
greppw-Funktionalität wiederhergestellt
Diffstat (limited to 'passwort-tresor.in')
-rw-r--r--[-rwxr-xr-x]passwort-tresor.in64
1 files changed, 52 insertions, 12 deletions
diff --git a/passwort-tresor.in b/passwort-tresor.in
index 9d6d3c6..29762c4 100755..100644
--- a/passwort-tresor.in
+++ b/passwort-tresor.in
@@ -5,25 +5,65 @@
echo "Dienst: "
read dienst
+beenden () {
+ [ -n "${tmpDir}" ] && rm -rf "${tmpDir}"
+ exit $1
+}
+
+beiFehlerBeenden () {
+ err=$?
+ if [ ${err} -ne 0 ]
+ then
+ if [ -e "${tmpDir}/humanStatus" ]
+ then
+ less "${tmpDir}/humanStatus"
+ fi
+ beenden ${err}
+ fi
+}
+
tmpDir="$(mktemp -d)"
-text="$(${passwortDateiBefehl} | gpg -o - -d - 2> "${tmpDir}/")"
+output="$(
+ ${passwortDateiBefehl} \
+ | tee "${tmpDir}/original" \
+ | gpg --status-fd 3 -d - \
+ 2> "${tmpDir}/humanStatus" \
+ 3> "${tmpDir}/status"
+)"
-if [ ! $(grep -c "Good signature from \"Erich Eckner \([^\"]*\)\?<erich@eckner.net>\"" ${tmpMsg}) -eq 1 ] || [ ! $(grep -c "Signature made .* using RSA key ID 0AEEC90755DA7B5A" ${tmpMsg}) -eq 1 ]
-then
- dialog --textbox ${tmpMsg} 14 70
-fi
+beiFehlerBeenden
+
+grep -q "VALIDSIG ${schluessel} \(.* \)\?${schluessel}\$" "${tmpDir}/status"
+
+beiFehlerBeenden
-rm -f ${tmpMsg}
+rm -f "${tmpDir}/humanStatus"
-[ $(echo -e "${text}" | grep -c "${dienst}") -gt 1 ] && dienst="^${dienst}"
-[ $(echo -e "${text}" | grep -c "${dienst}") -gt 1 ] && dienst="${dienst}:\$"
-[ $(echo -e "${text}" | grep -c "${dienst}") -eq 1 ] || exit 1
+${passwortSummenBefehl} \
+ | awk "{print \$1\" ${tmpDir}/original\"}" \
+ | sha512sum -c \
+ > "${tmpDir}/humanStatus"
-text="$(echo "${text}" | grep -2 "${dienst}" | tail -n2)"
-echo "${text}" | head -n1 | xclip -i
+beiFehlerBeenden
+
+sDienst="${dienst}"
+[ $(echo "${output}" | grep -c "${sDienst}") -gt 1 ] && sDienst="${dienst}.*:\$"
+[ $(echo "${output}" | grep -c "${sDienst}") -gt 1 ] && sDienst="^${dienst}.*:\$"
+[ $(echo "${output}" | grep -c "${sDienst}") -gt 1 ] && sDienst="^${dienst}:\$"
+if [ $(echo "${output}" | grep -c "${sDienst}") -ne 1 ]
+then
+ echo "'${dienst}' ist nicht genau ein Mal vorhanden, sondern $(echo "${output}" | grep -c "${sDienst}") Mal!"
+ beenden 1
+fi
+
+output="$(echo "${output}" | grep -2 "${dienst}" | tail -n2)"
+echo "${output}" | head -n1 | xclip -i
echo -n "."
read dienst
-echo "${text}" | tail -n1 | xclip -i
+echo "${output}" | tail -n1 | xclip -i
echo -n "."
read dienst
+echo "" | xclip -i
+
+beenden 0