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