Upgrade pinentry-wrapper to handle corner cases better

This commit is contained in:
Boris Ranto 2014-08-12 11:42:06 +02:00
parent 5b15124560
commit a6e2a0ad61
2 changed files with 52 additions and 41 deletions

87
pinentry-wrapper Normal file → Executable file
View File

@ -2,74 +2,81 @@
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2009 Fedora Project # Copyright (c) 2009 Fedora Project
# Copyright (c) 2014 Red Hat
# This file and all modifications and additions to the pristine # This file and all modifications and additions to the pristine
# package are under the same license as the package itself. # package are under the same license as the package itself.
# #
# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Please submit bugfixes or comments via http://bugzilla.redhat.com/
# #
# Anna Bernathova <anicka@novell.com> 2006 # Anna Bernathova <anicka@novell.com> 2006
# Pavel Nemec <pnemec@novell.com> 2006 # Pavel Nemec <pnemec@novell.com> 2006
# Rex Dieter <rdieter@fedoraproject.org> 2009 # Rex Dieter <rdieter@fedoraproject.org> 2009
# Pavol Rusnak <prusnak@novell.com> 2009
# Boris Ranto <branto@redhat.com> 2014
# #
# use proper binary (pinentry-qt, pinentry-gtk-2 or pinentry-curses) # use proper binary (pinentry-qt4, pinentry-qt, pinentry-gtk-2 or pinentry-curses)
if [ -z "$PINENTRY_BINARY" ]; then
kde_running= kde_running=
if [ -n "$KDE_FULL_SESSION" ]; then arg=
display=
# look for a --display option
for opt in "$@"; do
if [ "$opt" = "--display" ]; then
arg=1
elif [ -n "$arg" ]; then
display="$opt"
else
arg=
fi
done
# export DISPLAY if pinentry is meant to be run on a different display
# check the KDE_FULL_SESSION variable otherwise
if [ -n "$display" -a "$DISPLAY" != "$display" ]; then
export DISPLAY="$display"
elif [ -n "$KDE_FULL_SESSION" ]; then
kde_running=1 kde_running=1
elif [ -n "$DISPLAY" ]; then kde_ver="$KDE_SESSION_VERSION"
fi
# Check for presence of xprop binary
type xprop >/dev/null 2>/dev/null
XPROP=$?
if [ -n "$DISPLAY" -a $XPROP -eq 0 ]; then
xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
if test $? -eq 0; then if test $? -eq 0; then
kde_running=1 kde_running=1
fi kde_ver="`xprop -root | sed -n 's/KDE_SESSION_VERSION(CARDINAL) = //p'`" 2>/dev/null
else
arg=
display=
for opt in "$@"; do
if [ "$opt" = "--display" ]; then
arg=1
elif [ -n "$arg" ]; then
display="$opt"
else
arg=
fi
done
if [ -n "$display" ]; then
DISPLAY="$display" xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
if test $? -eq 0; then
kde_running=1
fi
fi fi
fi fi
# if a user supplied a pinentry binary, use it
if [ -n "$PINENTRY_BINARY" ];
then
export PINENTRY_BINARY="$PINENTRY_BINARY"
# if KDE is detected and pinentry-qt4 exists, use pinentry-qt4
elif [ -n "$kde_running" -a "$kde_ver"x = 4x -a -x /usr/bin/pinentry-qt4 ]
then
export PINENTRY_BINARY="/usr/bin/pinentry-qt4"
# if KDE is detected and pinentry-qt exists, use pinentry-qt # if KDE is detected and pinentry-qt exists, use pinentry-qt
if [ -n "$kde_running" -a -x /usr/bin/pinentry-qt ] elif [ -n "$kde_running" -a -x /usr/bin/pinentry-qt ]
then then
export PINENTRY_BINARY="/usr/bin/pinentry-qt" export PINENTRY_BINARY="/usr/bin/pinentry-qt"
# otherwise test if pinentry-gtk-2 is installed # otherwise test if pinentry-gtk-2 is installed
elif [ -x /usr/bin/pinentry-gtk-2 ] elif [ -n "$DISPLAY" -a -x /usr/bin/pinentry-gtk-2 ]
then then
export PINENTRY_BINARY="/usr/bin/pinentry-gtk-2" export PINENTRY_BINARY="/usr/bin/pinentry-gtk-2"
# otherwise test if pinentry-qt4 is installed # otherwise test if pinentry-qt4 exists although KDE is not detected
elif [ -x /usr/bin/pinentry-qt4 ] elif [ -n "$DISPLAY" -a -x /usr/bin/pinentry-qt4 ]
then then
export PINENTRY_BINARY="/usr/bin/pinentry-qt4" export PINENTRY_BINARY="/usr/bin/pinentry-qt4"
# otherwise test if pinentry-qt exists although KDE is not detected # otherwise test if pinentry-qt exists although KDE is not detected
elif [ -x /usr/bin/pinentry-qt ] elif [ -n "$DISPLAY" -a -x /usr/bin/pinentry-qt ]
then then
export PINENTRY_BINARY="/usr/bin/pinentry-qt" export PINENTRY_BINARY="/usr/bin/pinentry-qt"
# pinentry-curses is installed by default
else else
#test if gui binary is required
for opt in "$@"; do
if [ "x$opt" = "x--display" ]; then
# should not happen because of package dependencies
echo "Please install pinentry-gui" >&2
exit 1
fi
done
export PINENTRY_BINARY="/usr/bin/pinentry-curses" export PINENTRY_BINARY="/usr/bin/pinentry-curses"
fi fi
fi
exec $PINENTRY_BINARY "$@" exec $PINENTRY_BINARY "$@"

View File

@ -1,7 +1,7 @@
Name: pinentry Name: pinentry
Version: 0.8.3 Version: 0.8.3
Release: 5%{?dist} Release: 6%{?dist}
Summary: Collection of simple PIN or passphrase entry dialogs Summary: Collection of simple PIN or passphrase entry dialogs
# qt & qt4 subpackage have different license, see subpackage definitions # qt & qt4 subpackage have different license, see subpackage definitions
@ -126,6 +126,10 @@ fi
%changelog %changelog
* Tue Aug 12 2014 Boris Ranto <branto@redhat.com> - 0.8.3-6
- fix bogus dates
- upgrade pinentry-wrapper to handle corner cases better
* Wed Jul 30 2014 Tom Callaway <spot@fedoraproject.org> - 0.8.3-5 * Wed Jul 30 2014 Tom Callaway <spot@fedoraproject.org> - 0.8.3-5
- fix license handling - fix license handling