Initial commit
commit
4d101cf27b
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
# vim: set sw=4 ts=4 sts=4 et :
|
||||
|
||||
prompt_confirm() {
|
||||
result=$(pinentry -T $(tty) -g <<EOF | grep -E '^(D|ERR)'
|
||||
SETTITLE ssh-askpass
|
||||
SETDESC $1
|
||||
SETOK Yes
|
||||
SETCANCEL No
|
||||
CONFIRM
|
||||
EOF
|
||||
)
|
||||
echo "${result}" >&2
|
||||
case "${result}" in
|
||||
*cancelled*)
|
||||
exit 255
|
||||
;;
|
||||
'')
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "${result}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
prompt_notify() {
|
||||
pinentry -T $(tty) -g <<EOF || :
|
||||
SETTITLE ssh-askpass
|
||||
SETDESC $1
|
||||
SETTIMEOUT 3
|
||||
MESSAGE
|
||||
EOF
|
||||
}
|
||||
|
||||
prompt_passphrase() {
|
||||
result=$(pinentry -T $(tty) -g <<EOF | grep -E '^(D|ERR)'
|
||||
SETTITLE ssh-askpass
|
||||
SETDESC $1
|
||||
SETPROMPT Passphrase:
|
||||
GETPIN
|
||||
EOF
|
||||
)
|
||||
case "${result}" in
|
||||
*cancelled*)
|
||||
exit 255
|
||||
;;
|
||||
D*)
|
||||
echo "${result#D }"
|
||||
;;
|
||||
*)
|
||||
echo "${result}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
arg="$(echo "$1" | sed ':a;N;$!ba;s/\n/%0A/g')"
|
||||
case "${SSH_ASKPASS_PROMPT}" in
|
||||
confirm)
|
||||
prompt_confirm "${arg}"
|
||||
;;
|
||||
none)
|
||||
prompt_notify "${arg}"
|
||||
;;
|
||||
*)
|
||||
prompt_passphrase "${arg}"
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue