blob: 1bdab0e2ba38fb74783e89993db01647c5373218 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/bin/sh
# PRactice Password
# maybe will leak password to ps/top/htop and swap file
# not sure I only compare the password variables will leak or not
read_pass () {
stty -echo
# -r necessary because password may contain backslash \
read -r entered_pass
stty echo
}
pass_name="${1:-practice_password2}"
correct_pass="$(pass "$pass_name" | { IFS= read -r p; printf %s "$p";})"
echo "Enter password \"$pass_name\":"
read_pass
# `| { IFS= read -r p; printf %s "$p"; }` steal from <https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu#n34>, GPL-2.0-or-later; I use this because it is much faster than `| head -n1`
while ! [ "$entered_pass" = "$correct_pass" ]; do
echo "Wrong password, enter again:"
read_pass
done
# `. /bin/prp` will set these password variables as environment variables and can be accessed by the whole shell, so I unset these just in case
unset entered_pass
unset correct_pass
echo "Correct password"
|