mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-16 01:27:08 +00:00
Merge pull request #390 from dyne/pinentry_display_updates
updated pinentry invokation to include wayland
This commit is contained in:
commit
91debdbf58
101
tomb
101
tomb
@ -416,6 +416,7 @@ ask_password() {
|
|||||||
local password
|
local password
|
||||||
local gtkrc
|
local gtkrc
|
||||||
local theme
|
local theme
|
||||||
|
local pass_asked
|
||||||
|
|
||||||
# Distributions have broken wrappers for pinentry: they do
|
# Distributions have broken wrappers for pinentry: they do
|
||||||
# implement fallback, but they disrupt the output somehow. We are
|
# implement fallback, but they disrupt the output somehow. We are
|
||||||
@ -428,70 +429,54 @@ ask_password() {
|
|||||||
|
|
||||||
_verbose "asking password with tty=$TTY lc-ctype=$LANG"
|
_verbose "asking password with tty=$TTY lc-ctype=$LANG"
|
||||||
|
|
||||||
if [[ "$DISPLAY" = "" ]]; then
|
pass_asked=0
|
||||||
|
|
||||||
if _is_found "pinentry-curses"; then
|
if [[ "$WAYLAND_DISPLAY" ]]; then
|
||||||
_verbose "using pinentry-curses"
|
_verbose "wayland display detected"
|
||||||
output=$(pinentry_assuan_getpass | pinentry-curses)
|
_is_found "pinentry-gnome3" && {
|
||||||
else
|
_verbose "using pinentry-gnome3 on wayland"
|
||||||
_failure "Cannot find pinentry-curses and no DISPLAY detected."
|
output=$(pinentry_assuan_getpass | pinentry-gnome3)
|
||||||
fi
|
pass_asked=1
|
||||||
|
}
|
||||||
else # a DISPLAY is found to be active
|
fi
|
||||||
|
if [[ "$DISPLAY" ]] && [[ "$pass_asked" == 0 ]]; then
|
||||||
# customized gtk2 dialog with a skull (if extras are installed)
|
_verbose "X11 display detected"
|
||||||
if _is_found "pinentry-gtk-2"; then
|
if _is_found "pinentry-gtk-2"; then
|
||||||
_verbose "using pinentry-gtk2"
|
_verbose "using pinentry-gtk2"
|
||||||
|
|
||||||
gtkrc=""
|
|
||||||
theme=/share/themes/tomb/gtk-2.0-key/gtkrc
|
|
||||||
for i in /usr/local /usr; do
|
|
||||||
[[ -r $i/$theme ]] && {
|
|
||||||
gtkrc="$i/$theme"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
done
|
|
||||||
[[ "$gtkrc" = "" ]] || {
|
|
||||||
gtkrc_old="$GTK2_RC_FILES"
|
|
||||||
export GTK2_RC_FILES="$gtkrc"
|
|
||||||
}
|
|
||||||
output=$(pinentry_assuan_getpass | pinentry-gtk-2)
|
output=$(pinentry_assuan_getpass | pinentry-gtk-2)
|
||||||
[[ "$gtkrc" = "" ]] || export GTK2_RC_FILES="$gtkrc_old"
|
pass_asked=1
|
||||||
|
|
||||||
# TODO QT5 customization of dialog
|
|
||||||
elif _is_found "pinentry-qt5"; then
|
|
||||||
_verbose "using pinentry-qt5"
|
|
||||||
|
|
||||||
output=$(pinentry_assuan_getpass | pinentry-qt5)
|
|
||||||
|
|
||||||
# TODO QT4 customization of dialog
|
|
||||||
elif _is_found "pinentry-qt4"; then
|
|
||||||
_verbose "using pinentry-qt4"
|
|
||||||
|
|
||||||
output=$(pinentry_assuan_getpass | pinentry-qt4)
|
|
||||||
# TODO X11 customization of dialog
|
|
||||||
elif _is_found "pinentry-x11"; then
|
elif _is_found "pinentry-x11"; then
|
||||||
_verbose "using pinentry-x11"
|
_verbose "using pinentry-x11"
|
||||||
|
|
||||||
output=$(pinentry_assuan_getpass | pinentry-x11)
|
output=$(pinentry_assuan_getpass | pinentry-x11)
|
||||||
|
pass_asked=1
|
||||||
else
|
elif _is_found "pinentry-gnome3"; then
|
||||||
|
_verbose "using pinentry-gnome3 on X11"
|
||||||
if _is_found "pinentry-curses"; then
|
output=$(pinentry_assuan_getpass | pinentry-gnome3)
|
||||||
_verbose "using pinentry-curses"
|
pass_asked=1
|
||||||
|
elif _is_found "pinentry-qt5"; then
|
||||||
_verbose "Detected DISPLAY, but only pinentry-curses is found."
|
_verbose "using pinentry-qt5"
|
||||||
output=$(pinentry_assuan_getpass | pinentry-curses)
|
output=$(pinentry_assuan_getpass | pinentry-qt5)
|
||||||
else
|
pass_asked=1
|
||||||
_failure "Cannot find any pinentry: impossible to ask for password."
|
elif _is_found "pinentry-qt4"; then
|
||||||
fi
|
_verbose "using pinentry-qt4"
|
||||||
|
output=$(pinentry_assuan_getpass | pinentry-qt4)
|
||||||
|
pass_asked=1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "$pass_asked" == 0 ]]; then
|
||||||
|
_verbose "no display detected"
|
||||||
|
_is_found "pinentry-curses" && {
|
||||||
|
_verbose "using pinentry-curses with no display"
|
||||||
|
output=$(pinentry_assuan_getpassgetpasspass | pinentry-curses)
|
||||||
|
pass_asked=1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
fi # end of DISPLAY block
|
[[ "$pass_asked" == 0 ]] &&
|
||||||
|
_failure "Cannot find any pinentry-curses and no DISPLAY detected."
|
||||||
|
|
||||||
# parse the pinentry output
|
# parse the pinentry output
|
||||||
local pinentry_error
|
local pinentry_error
|
||||||
for i in ${(f)output}; do
|
for i in ${(f)output}; do
|
||||||
[[ "$i" =~ "^ERR.*" ]] && {
|
[[ "$i" =~ "^ERR.*" ]] && {
|
||||||
pinentry_error="${i[(w)3]}"
|
pinentry_error="${i[(w)3]}"
|
||||||
@ -501,11 +486,11 @@ ask_password() {
|
|||||||
[[ "$i" =~ "^D .*" ]] && password="${i##D }";
|
[[ "$i" =~ "^D .*" ]] && password="${i##D }";
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ ! -z "$pinentry_error" ]] && [[ "$password" = "" ]] && {
|
[[ ! -z "$pinentry_error" ]] && [[ "$password" = "" ]] && {
|
||||||
_warning "Pinentry error: ::1 error::" ${pinentry_error}
|
_warning "Pinentry error: ::1 error::" ${pinentry_error}
|
||||||
print "canceled"
|
print "canceled"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# if sphinx mode is chosen, use the provided input
|
# if sphinx mode is chosen, use the provided input
|
||||||
# as master password to retrieve the actual password
|
# as master password to retrieve the actual password
|
||||||
|
Loading…
Reference in New Issue
Block a user