2021-01-06 15:49:45 +00:00
|
|
|
#!/usr/bin/sh
|
2014-09-27 18:52:58 +00:00
|
|
|
|
|
|
|
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
|
|
# Copyright (c) 2009 Fedora Project
|
2015-10-15 13:08:37 +00:00
|
|
|
# Copyright (c) 2014-2015 Red Hat
|
2014-09-27 18:52:58 +00:00
|
|
|
# This file and all modifications and additions to the pristine
|
|
|
|
# package are under the same license as the package itself.
|
|
|
|
#
|
|
|
|
# Please submit bugfixes or comments via http://bugzilla.redhat.com/
|
|
|
|
#
|
|
|
|
# Anna Bernathova <anicka@novell.com> 2006
|
|
|
|
# Pavel Nemec <pnemec@novell.com> 2006
|
|
|
|
# Rex Dieter <rdieter@fedoraproject.org> 2009
|
|
|
|
# Pavol Rusnak <prusnak@novell.com> 2009
|
|
|
|
# Boris Ranto <branto@redhat.com> 2014
|
|
|
|
#
|
2018-01-01 15:10:30 +00:00
|
|
|
# use proper binary (pinentry-qt, pinentry-gnome, pinentry-gtk-2 or pinentry-curses)
|
2014-09-27 18:52:58 +00:00
|
|
|
|
|
|
|
kde_running=
|
|
|
|
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
|
2021-04-14 15:34:59 +00:00
|
|
|
if [ -n "$display" ] && [ "$DISPLAY" != "$display" ]; then
|
2014-09-27 18:52:58 +00:00
|
|
|
export DISPLAY="$display"
|
|
|
|
elif [ -n "$KDE_FULL_SESSION" ]; then
|
|
|
|
kde_running=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for presence of xprop binary
|
|
|
|
type xprop >/dev/null 2>/dev/null
|
|
|
|
XPROP=$?
|
|
|
|
|
2021-04-14 15:34:59 +00:00
|
|
|
if [ -n "$DISPLAY" ] && [ $XPROP -eq 0 ]; then
|
2014-09-27 18:52:58 +00:00
|
|
|
xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
|
|
|
|
if test $? -eq 0; then
|
|
|
|
kde_running=1
|
|
|
|
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-qt exists, use pinentry-qt
|
2021-04-14 15:34:59 +00:00
|
|
|
elif [ -n "$kde_running" ] && [ -x /usr/bin/pinentry-qt ]
|
2014-09-27 18:52:58 +00:00
|
|
|
then
|
|
|
|
export PINENTRY_BINARY="/usr/bin/pinentry-qt"
|
2015-10-15 13:08:37 +00:00
|
|
|
# otherwise test if pinentry-gnome3 is installed
|
2021-04-14 15:34:59 +00:00
|
|
|
elif [ -n "$DISPLAY" ] && [ -x /usr/bin/pinentry-gnome3 ]
|
2015-10-15 13:08:37 +00:00
|
|
|
then
|
|
|
|
export PINENTRY_BINARY="/usr/bin/pinentry-gnome3"
|
2014-09-27 18:52:58 +00:00
|
|
|
# otherwise test if pinentry-gtk-2 is installed
|
2021-04-14 15:34:59 +00:00
|
|
|
elif [ -n "$DISPLAY" ] && [ -x /usr/bin/pinentry-gtk-2 ]
|
2014-09-27 18:52:58 +00:00
|
|
|
then
|
|
|
|
export PINENTRY_BINARY="/usr/bin/pinentry-gtk-2"
|
|
|
|
# otherwise test if pinentry-qt exists although KDE is not detected
|
2021-04-14 15:34:59 +00:00
|
|
|
elif [ -n "$DISPLAY" ] && [ -x /usr/bin/pinentry-qt ]
|
2014-09-27 18:52:58 +00:00
|
|
|
then
|
|
|
|
export PINENTRY_BINARY="/usr/bin/pinentry-qt"
|
2021-01-26 09:52:33 +00:00
|
|
|
# use pinentry-tty if installed
|
|
|
|
elif [ -x /usr/bin/pinentry-tty ]
|
2021-01-06 15:49:45 +00:00
|
|
|
then
|
|
|
|
export PINENTRY_BINARY="/usr/bin/pinentry-tty"
|
2021-01-26 09:52:33 +00:00
|
|
|
# pinentry-curses is installed by default
|
|
|
|
else
|
|
|
|
export PINENTRY_BINARY="/usr/bin/pinentry-curses"
|
2014-09-27 18:52:58 +00:00
|
|
|
fi
|
|
|
|
exec $PINENTRY_BINARY "$@"
|