From ec9e441825b0a4b1780f9f3b416e491c4012b5dd Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 19 Aug 2016 13:01:34 +0200 Subject: greppw-Funktionalität wiederhergestellt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- passwort-tresor.in | 64 ++++++++++++++++++++++++++++++++++++++++++---------- passwort-tresor.konf | 6 +++-- 2 files changed, 56 insertions(+), 14 deletions(-) mode change 100755 => 100644 passwort-tresor.in diff --git a/passwort-tresor.in b/passwort-tresor.in old mode 100755 new mode 100644 index 9d6d3c6..29762c4 --- 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 \([^\"]*\)\?\"" ${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 diff --git a/passwort-tresor.konf b/passwort-tresor.konf index 168e2e0..91f21e0 100644 --- a/passwort-tresor.konf +++ b/passwort-tresor.konf @@ -1,4 +1,6 @@ #!/bin/bash -passwortDateiBefehl='ssh nlopc46 "cat ~/Dokumente/pws.gpg"' -passwortSummenBefehl='ssh nlopc43 "cat .sums/pws.512"' +schluessel='DE9F7688CACF04FEB81A6C590AEEC90755DA7B5A' + +passwortDateiBefehl="ssh nlopc46 cat Dokumente/pws.gpg" +passwortSummenBefehl="ssh nlopc43 cat .sums/pws.512" -- cgit v1.2.3-70-g09d2