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