Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Originating-IP: [68.107.52.110] From: "Karl M" To: cygwin AT cygwin DOT com Subject: keychain patch (2) Date: Sun, 16 Mar 2003 12:12:48 -0800 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_5e21_5f23_4af9" Message-ID: X-OriginalArrivalTime: 16 Mar 2003 20:12:48.0530 (UTC) FILETIME=[6A293F20:01C2EBF8] Note-from-DJ: This may be spam ------=_NextPart_000_5e21_5f23_4af9 Content-Type: text/plain; format=flowed Hi All... I made a small patch to keychain, so that it creates an additional pid file named ~/ssh-agent.cmd The only difference between this and the previous version is that the file created is ~/ssh-agent.cmd instead of ~/ssh-agent.bat so it is a bit less obtrusive. I couldn't do a ~/.ssh-agent-cmd file because the call mechanism in cmd.exe handles it differently (uses a different shell instead of the same shell). This allows non-cygwin ssh-aware programs (such as unison) to take advantage of the keychain functionality. The new file can be used from a windows command script by @echo off call bash --login /dev/null call C:\Cygwin\home\kmoerder\ssh-agent.cmd unison-2.9.1 The call to bash invokes the keychain in the .profile to get the keys ready then the call to ssh-agent.cmd defines the env variables for non-cygwin ssh-aware programs (such as unison). Thanks, ...Karl _________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail ------=_NextPart_000_5e21_5f23_4af9 Content-Type: text/plain; name="keychain-patch"; format=flowed Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="keychain-patch" --- 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 ${@} | 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 ------=_NextPart_000_5e21_5f23_4af9 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ------=_NextPart_000_5e21_5f23_4af9--