mail: Fix checkmail script password bugging
Fixed script to only ask for password once before understanding that the user does not want to provide it. Since gpg seems to not differentiate between a *wrongly* entered password and one entered not at all, we have to assume the user canceled the password prompt and not bug him again until the next time the script is invoked. It will, however, at least notify the user that the process is aborted in a quick notification message, so that if it was done on accident the user will still know what's up.
This commit is contained in:
parent
f94759697d
commit
78b47a35b2
1 changed files with 66 additions and 54 deletions
|
@ -68,17 +68,27 @@ checkonline() {
|
|||
checkwarnuser() {
|
||||
agt=$(gpg2 --decrypt --no-tty --quiet --no-verbose --for-your-eyes-only --pinentry-mode cancel "$PASSWORD_FILE" 2>&1)
|
||||
if echo "$agt" | grep -qE 'No secret key'; then
|
||||
notify "Mail: Password phrase needed!"
|
||||
notify "Mail" "Password phrase needed!"
|
||||
sleep 2.5
|
||||
fi
|
||||
}
|
||||
|
||||
enablegpgagent() {
|
||||
## get password from user
|
||||
agt=$(gpg2 --decrypt --no-tty --quiet --no-verbose --for-your-eyes-only --pinentry-mode ask "$PASSWORD_FILE" 2>&1)
|
||||
## exit program after first failed attempt
|
||||
if echo "$agt" | grep -qE 'decryption failed'; then
|
||||
notify "Mail" "Process aborted."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# send out a notification on new mail, to libnotify and stdout
|
||||
notifymail() {
|
||||
[ "${MBSYNC_NOTIFY:-1}" -eq 0 ] && return
|
||||
|
||||
if [ "${HASMAIL:-0}" -gt 0 ]; then
|
||||
notify "($HASMAIL) new mail"
|
||||
notify "Mail" "New Mail ($HASMAIL)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -100,6 +110,8 @@ fi
|
|||
main() {
|
||||
checkwarnuser
|
||||
|
||||
enablegpgagent
|
||||
|
||||
prehook
|
||||
|
||||
tries=0
|
||||
|
|
Loading…
Reference in a new issue