--- /usr/bin/keychain-orig 2003-02-21 16:13:20.000000000 -0500 +++ /usr/bin/keychain 2003-02-21 17:47:26.000000000 -0500 @@ -325,6 +325,53 @@ fi done +# Added 21-Feb-2003 kronenpj@netzero.net +# Try to play nice with an existing ssh-agent. +if [ "x$mypids" != "x" ]; then + # Find the first one owned by $USE in /tmp + mydirs=`/bin/ls -l /tmp/ | grep ssh- | grep $USER | head -1` + + if [ -n "$mydirs" ] + then + set $mydirs + mydirs=$9 + fi + + gspids=`ps $psopts 2>/dev/null | grep "gnome-session"` > /dev/null 2>&1 + # Extract the gnome-session pid + if [ -n "$gspids" ]; then + set $gspids + gspids=$2 + fi + + # Nab the name of the socket + mysock=`/bin/ls -1 /tmp/$mydirs/agent.$gspids` + + if [ -w $mysock ]; then + if [ -z "$quietopt" ] + then + echo $E " ${GREEN}*${OFF} All previously running ssh-agent(s) have been stopped." + echo $E " ${GREEN}*${OFF} Initializing ${pidf} file..." + fi + + # "> pidf" doesn't work ash. But it should work with any sh-compatible shell + > "$pidf" || { echo "$0: Cannot create ${pidf}; exiting." 1>&2; rm -f "$pidf" "$cshpidf" "$lockf" 2> /dev/null; exit 1; } + [ -z "$quietopt" ] && echo $E " ${GREEN}*${OFF} Initializing ${cshpidf} file..." + > "$cshpidf" || { echo "$0: Cannot create ${cshpidf}; exiting." 1>&2; rm -f "$pidf" "$cshpidf" "$lockf" 2> /dev/null; exit 1; } + chmod 0600 "$pidf" "$cshpidf" + [ -z "$quietopt" ] && echo $E " ${GREEN}*${OFF} Using existing ssh-agent" + echo "SSH_AUTH_SOCK=$mysock; export SSH_AUTH_SOCK;" > $pidf + echo "SSH_AGENT_PID=$mypids; export SSH_AGENT_PID;" >> $pidf + . "$pidf" + echo "setenv $SSH_AUTH_SOCK_NAME $SSH_AUTH_SOCK;" > "$cshpidf" + echo "setenv $SSH_AGENT_PID_NAME $SSH_AGENT_PID;" >> "$cshpidf" + + # Bypass the remainder of the "destructive stuff." + match="yes" + fi +fi +# END - Added 21-Feb-2003 kronenpj@netzero.net + if [ "$match" = "no" ] then if [ -n "$mypids" ]