
if test -n $GPG_AGENT_INFO ; then
    if test -n "$SSH_AUTH_SOCK" -a "$usessh" = yes ; then
	export SSH_AUTH_SOCK
    fi
else
    if test -n "$SSH_AUTH_SOCK" -a "$usessh" != yes ; then
	unset SSH_AUTH_SOCK
    fi
fi

#
# Run ssh-agent only if ssh service is configured and avaliable.
# Check if there is already a running ssh-agent and if use this.
#
if test "$usessh" = yes -a -d "$HOME/.ssh" && sshagent=$(type -p ssh-agent) ; then
    if test -S "$SSH_AUTH_SOCK" ; then
	if test -n "$SSH_AGENT_PID" && checkproc -p $SSH_AGENT_PID $sshagent ; then
	    export SSH_AGENT_PID SSH_AUTH_SOCK
	else
	    rm -f "$SSH_AUTH_SOCK"
	    case "${SSH_AUTH_SOCK%/*}" in
	    /tmp/*) rm -rf "${SSH_AUTH_SOCK%/*}"
	    esac
	    unset SSH_AUTH_SOCK
	fi
    else
	unset SSH_AUTH_SOCK
    fi

    if test -z "$SSH_AUTH_SOCK" ; then
	set -- $sshagent ${1+"$@"}
    fi
fi

if [ "$usessh" != no ]; then
    if test -x /usr/lib/ssh/ssh-askpass ; then
	SSH_ASKPASS=/usr/lib/ssh/ssh-askpass
	export SSH_ASKPASS
    elif test -x /usr/lib64/ssh/ssh-askpass ; then
	SSH_ASKPASS=/usr/lib64/ssh/ssh-askpass
	export SSH_ASKPASS
    fi
fi
