Fast fail if password file is missing.

This commit is contained in:
drduh 2015-08-07 14:11:11 -04:00
parent f42437388d
commit 09adcb0b95
2 changed files with 12 additions and 10 deletions

View File

@ -36,7 +36,9 @@ The script and `pwd.sh.safe` encrypted file can be safely shared between machine
A sample `gpg.conf` configuration file is provided for your consideration.
# Alternatives
# Recommended software
[Pass: the standard unix password manager](http://www.passwordstore.org/)
[sf-pwgen: generates passwords using OS X Security framework](https://github.com/anders/pwgen)

8
pwd.sh
View File

@ -68,6 +68,10 @@ encrypt () {
read_pass () {
# Read a password from safe.
if [[ ! -s ${safe} ]] ; then
fail "No passwords found"
fi
if [[ -z "${2+x}" ]] ; then
read -p "
Username to read? (default: all) " username
@ -79,14 +83,10 @@ read_pass () {
username=""
fi
if [[ ! -s ${safe} ]] ; then
fail "No passwords found"
else
get_pass "
Enter password to unlock ${safe}: "
printf "\n\n"
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
fi
}