From 74fa20029f198258a14ca6ad3fb6ca14a9714188 Mon Sep 17 00:00:00 2001 From: samedamci Date: Tue, 10 Mar 2020 21:24:23 +0100 Subject: [PATCH] Add database password verification in passworder script --- botfiles/.scripts/passworder.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/botfiles/.scripts/passworder.sh b/botfiles/.scripts/passworder.sh index 3ac6e3a..97fc6ec 100755 --- a/botfiles/.scripts/passworder.sh +++ b/botfiles/.scripts/passworder.sh @@ -1,7 +1,17 @@ #!/usr/bin/env zsh -rofi -dmenu -i -p "Enter your database password" -l 0 -password | read DBpass +CACHE=$HOME/.cache/passworder/ +mkdir -p $CACHE +DB="$HOME/Passwords/keepass.kdbx" -echo $DBpass | keepassxc-cli ls ~/Passwords/keepass.kdbx | grep -v 'Enter' | rofi -dmenu -i -p "Entry list" -l 30 | read entry +rofi -dmenu -i -p "Enter your database password" -l 0 -password | read DBPASS -echo $DBpass | keepassxc-cli clip ~/Passwords/keepass.kdbx $entry +ERROR_MSG='Error while reading the database' +CHECK=$(echo $DBPASS | keepassxc-cli open $DB &> $CACHE/tmp && grep -oh $ERROR_MSG $CACHE/tmp) + +if [ "$CHECK" = "$ERROR_MSG" ]; then + rofi -e "$ERROR_MSG" +else + echo $DBPASS | keepassxc-cli ls $DB | grep -v 'Enter' | grep -v '?*/' | sort | rofi -dmenu -i -p "Entry list" -l 30 | read ENTRY + echo $DBPASS | keepassxc-cli clip $DB $ENTRY +fi