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