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