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)

18
pwd.sh
View File

@ -68,25 +68,25 @@ 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
else
username="${2}"
username="${2}"
fi
if [[ -z ${username} || ${username} == "all" ]] ; then
username=""
fi
if [[ ! -s ${safe} ]] ; then
fail "No passwords found"
else
get_pass "
get_pass "
Enter password to unlock ${safe}: "
printf "\n\n"
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
fi
printf "\n\n"
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
}
@ -167,7 +167,7 @@ create_username () {
fi
if [[ -z "${4+x}" || ! "${4}" =~ ^([qQ])$ ]] ; then
echo "
echo "
Password: ${userpass}"
fi
}