mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-12-01 17:23:58 +00:00
Direct handling of pinentry execution
We skip distro wrappers here since they interfere with stdin/out As usual: better to have less intermediaries.
This commit is contained in:
parent
1ef2576b16
commit
bbe9a49ec3
81
tomb
81
tomb
@ -160,7 +160,14 @@ TRAPSTOP() { _endgame STOP }
|
|||||||
|
|
||||||
_cat() { local -a _arr;
|
_cat() { local -a _arr;
|
||||||
# read file using mapfile, newline fix
|
# read file using mapfile, newline fix
|
||||||
_arr=("${(f@)${mapfile[${1}]%$’\n’}}"); print "$_arr" }
|
_arr=("${(f@)${mapfile[${1}]%$’\n’}}"); print "$_arr"
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_found() {
|
||||||
|
# returns 0 if binary if found in path
|
||||||
|
[[ "$1" = "" ]] && return 1
|
||||||
|
return command -v "$1" 1>/dev/null 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# Identify the running user
|
# Identify the running user
|
||||||
# Set global variables _UID, _GID, _TTY, and _USER, either from the
|
# Set global variables _UID, _GID, _TTY, and _USER, either from the
|
||||||
@ -343,6 +350,33 @@ ask_password() {
|
|||||||
local gtkrc
|
local gtkrc
|
||||||
local theme
|
local theme
|
||||||
|
|
||||||
|
# Distributions have broken wrappers for pinentry: they do
|
||||||
|
# implement fallback, but they disrupt the output somehow. We are
|
||||||
|
# better off relying on less intermediaries, so we implement our
|
||||||
|
# own fallback mechanisms. Pinentry supported: curses, gtk-2, qt4
|
||||||
|
# and x11.
|
||||||
|
|
||||||
|
if [[ "$DISPLAY" = "" ]]; then
|
||||||
|
|
||||||
|
if _is_found "pinentry-curses"; then
|
||||||
|
|
||||||
|
output=`cat <<EOF | pinentry-curses
|
||||||
|
OPTION ttyname=$TTY
|
||||||
|
OPTION lc-ctype=$LANG
|
||||||
|
SETTITLE $title
|
||||||
|
SETDESC $description
|
||||||
|
SETPROMPT Password:
|
||||||
|
GETPIN
|
||||||
|
EOF`
|
||||||
|
else
|
||||||
|
_failure "Cannot find pinentry-curses and no DISPLAY detected."
|
||||||
|
fi
|
||||||
|
|
||||||
|
else # a DISPLAY is found to be active
|
||||||
|
|
||||||
|
# customized gtk2 dialog with a skull (if extras are installed)
|
||||||
|
if _is_found "pinentry-gtk-2"; then
|
||||||
|
|
||||||
[[ "$DISPLAY" = "" ]] || {
|
[[ "$DISPLAY" = "" ]] || {
|
||||||
theme=/share/themes/tomb/gtk-2.0-key/gtkrc
|
theme=/share/themes/tomb/gtk-2.0-key/gtkrc
|
||||||
for i in /usr/local /usr; do
|
for i in /usr/local /usr; do
|
||||||
@ -360,6 +394,51 @@ SETPROMPT Password:
|
|||||||
GETPIN
|
GETPIN
|
||||||
EOF`
|
EOF`
|
||||||
|
|
||||||
|
# TODO QT4 customization of dialog
|
||||||
|
elif _is_found "pinentry-qt4"; then
|
||||||
|
|
||||||
|
output=`cat <<EOF | pinentry-qt4
|
||||||
|
OPTION ttyname=$TTY
|
||||||
|
OPTION lc-ctype=$LANG
|
||||||
|
SETTITLE $title
|
||||||
|
SETDESC $description
|
||||||
|
SETPROMPT Password:
|
||||||
|
GETPIN
|
||||||
|
EOF`
|
||||||
|
|
||||||
|
# TODO X11 customization of dialog
|
||||||
|
elif _is_found "pinentry-x11"; then
|
||||||
|
|
||||||
|
output=`cat <<EOF | pinentry-x11
|
||||||
|
OPTION ttyname=$TTY
|
||||||
|
OPTION lc-ctype=$LANG
|
||||||
|
SETTITLE $title
|
||||||
|
SETDESC $description
|
||||||
|
SETPROMPT Password:
|
||||||
|
GETPIN
|
||||||
|
EOF`
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
if _is_found "pinentry-curses"; then
|
||||||
|
|
||||||
|
_warning "Detected DISPLAY, but only pinentry-curses is found."
|
||||||
|
output=`cat <<EOF | pinentry-curses
|
||||||
|
OPTION ttyname=$TTY
|
||||||
|
OPTION lc-ctype=$LANG
|
||||||
|
SETTITLE $title
|
||||||
|
SETDESC $description
|
||||||
|
SETPROMPT Password:
|
||||||
|
GETPIN
|
||||||
|
EOF`
|
||||||
|
else
|
||||||
|
_failure "Cannot find any pinentry: impossible to ask for password."
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi # end of DISPLAY block
|
||||||
|
|
||||||
# parse the pinentry output
|
# parse the pinentry output
|
||||||
for i in ${(f)output}; do
|
for i in ${(f)output}; do
|
||||||
[[ "$i" =~ "^ERR.*" ]] && {
|
[[ "$i" =~ "^ERR.*" ]] && {
|
||||||
|
Loading…
Reference in New Issue
Block a user