mirror of
https://github.com/octoleo/Purse.git
synced 2025-02-11 08:18:26 +00:00
Option to read password by username
This commit is contained in:
parent
25122d0549
commit
c8e0f6d494
@ -20,7 +20,7 @@ Run the script with `./pwd.sh`
|
|||||||
|
|
||||||
Type `w` to write a password.
|
Type `w` to write a password.
|
||||||
|
|
||||||
Type `r` to read passwords. Pipe to `grep` and `pbcopy` or `xsel`, for example.
|
Type `r` to read a password or all passwords.
|
||||||
|
|
||||||
Type `d` to delete a password.
|
Type `d` to delete a password.
|
||||||
|
|
||||||
|
8
pwd.sh
8
pwd.sh
@ -59,11 +59,15 @@ encrypt () {
|
|||||||
read_pass () {
|
read_pass () {
|
||||||
# Read a password from safe.
|
# Read a password from safe.
|
||||||
|
|
||||||
|
if [[ -z ${username} || ${username} == "all" ]] ; then
|
||||||
|
username=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -s ${safe} ] ; then
|
if [ ! -s ${safe} ] ; then
|
||||||
fail "No passwords found"
|
fail "No passwords found"
|
||||||
else
|
else
|
||||||
get_pass "Enter password to unlock ${safe}: " ; echo
|
get_pass "Enter password to unlock ${safe}: " ; echo
|
||||||
decrypt ${password} ${safe} || fail "Decryption failed"
|
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +124,7 @@ create_username () {
|
|||||||
userpass=$password
|
userpass=$password
|
||||||
else
|
else
|
||||||
userpass=$(gen_pass)
|
userpass=$(gen_pass)
|
||||||
|
echo "Password: ${userpass}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +148,7 @@ elif [ "${action}" == "d" ] ; then
|
|||||||
read -p "Username to delete? " username
|
read -p "Username to delete? " username
|
||||||
write_pass
|
write_pass
|
||||||
else
|
else
|
||||||
|
read -p "Username to read? (default: all) " username
|
||||||
read_pass
|
read_pass
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user