--- keychain 2003-03-16 11:30:55.000000000 -0800 +++ /bin/keychain 2003-03-16 11:13:53.000000000 -0800 @@ -17,20 +17,22 @@ # simultaneously (only works if lockfile from the procmail package is # available. hostname=`uname -n` if [ -z "`echo ${ at } | grep '\-\-local'`" ] then pidf="${HOME}/.ssh-agent-${hostname}" cshpidf="${HOME}/.ssh-agent-csh-${hostname}" + batpidf="${HOME}/ssh-agent${hostname}.cmd" lockf="${HOME}/.keychain-lock-${hostname}" else pidf="${HOME}/.ssh-agent" cshpidf="${HOME}/.ssh-agent-csh" + batpidf="${HOME}/ssh-agent.cmd" lockf="${HOME}/.keychain-lock" fi # perform lock if we have lockfile available if type lockfile >/dev/null 2>&1; then lockfile -1 -r 30 -l 35 -s 2 "$lockf" if [ $? != 0 ]; then echo "Error: Couldn't get lock" >&2 @@ -83,17 +85,17 @@ #End special cygwin version mypids=`ps $psopts 2>/dev/null | grep "[s]sh-agent" | awk '{print $2}'` > /dev/null 2>&1 if [ -n "`echo $* | grep '\-\-stop'`" ] || [ -n "`echo $* | grep '\-k'`" ] then # --stop tells keychain to kill the existing ssh-agent(s), then exit kill $mypids > /dev/null 2>&1 - rm -f "${pidf}" "${cshpidf}" "$lockf" 2> /dev/null + rm -f "${pidf}" "${cshpidf}" "${batpidf}" "$lockf" 2> /dev/null #`whoami` (rather than the $LOGNAME var) gives us the euid rather than the uid (what we want) if [ "$quiet_mode" = "no" ] then echo $E " ${GREEN}*${OFF} All ssh-agent(s) started by" `whoami` "are now stopped." echo fi exit 0 fi @@ -219,25 +221,29 @@ kill $mypids > /dev/null 2>&1 fi if [ "$quiet_mode" = "no" ] 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; } + > "$pidf" || { echo "$0: Cannot create ${pidf}; exiting." 1>&2; rm -f "$pidf" "$cshpidf" "$batpidf" "$lockf" 2> /dev/null; exit 1; } [ "$quiet_mode" = "no" ] && 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" + > "$cshpidf" || { echo "$0: Cannot create ${cshpidf}; exiting." 1>&2; rm -f "$pidf" "$cshpidf" "$batpidf" "$lockf" 2> /dev/null; exit 1; } + [ "$quiet_mode" = "no" ] && echo $E " ${GREEN}*${OFF} Initializing ${batpidf} file..." + > "$batpidf" || { echo "$0: Cannot create ${batpidf}; exiting." 1>&2; rm -f "$pidf" "$cshpidf" "$batpidf" "$lockf" 2> /dev/null; exit 1; } + chmod 0600 "$pidf" "$cshpidf" "$batpidf" [ "$quiet_mode" = "no" ] && echo $E " ${GREEN}*${OFF} Starting new ssh-agent" nohup ssh-agent -s | grep -v 'Agent pid' > "$pidf" . "$pidf" echo "setenv SSH_AUTH_SOCK $SSH_AUTH_SOCK;" > "$cshpidf" echo "setenv SSH_AGENT_PID $SSH_AGENT_PID;" >> "$cshpidf" + echo "@set SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > "$batpidf" + echo "@set SSH_AGENT_PID=$SSH_AGENT_PID" >> "$batpidf" fi if [ -n "`echo $* | grep '\-\-clear'`" ] then echo $E " ${GREEN}*${OFF} \c" ssh-add -D fi