Blame SOURCES/pinentry-wrapper

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