Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

install.sh does not backup updated ssh-agent.exe #10

Open
codex24 opened this Issue Mar 22, 2012 · 1 comment

Comments

Projects
None yet
1 participant

codex24 commented Mar 22, 2012

I noticed that after having installed charade, that when I update the CygWin native ssh-agent.exe it overwrites the /usr/local/ssh-agent.exe symlink to charade.exe, as expected. However, when I re-run charade's install.sh, its logic does not account for the native ssh-agent.exe and ssh-agent-orig.exe not being copies of the same file. As a result, the newly updated native ssh-agent.exe is ignored for backup and overwritten with the symlink when it is written, keeping the original backup of an old version of the native ssh-agent.exe around forever.

codex24 commented Mar 22, 2012

I am providing a patch to correct this issue:

$ cat install.patch
--- install.sh~ 2011-11-09 13:33:36.593812200 -0600
+++ install.sh  2012-03-22 16:16:11.348055000 -0500
@@ -9,10 +9,16 @@
 echo "Backing up old /usr/bin/ssh-agent.exe ..."
 if [ -e /usr/bin/ssh-agent.exe ]; then
     if [ -f /usr/bin/ssh-agent-orig.exe ]; then
-        echo -n "  Backup already exists: just removing old ssh-agent.exe ..."
-        rm /usr/bin/ssh-agent.exe
-        echo done
-    else
+               if [ -L /usr/bin/ssh-agent.exe ]; then
+               echo -n "  Backup already exists: just removing old ssh-agent.exe ..."
+               rm /usr/bin/ssh-agent.exe
+               echo done
+               elif [[ $(stat -c %s /usr/bin/ssh-agent.exe) -ne $(stat -c %s /usr/bin/ssh-agent-orig.exe) ]] ; then
+               echo -n "  Updated ssh-agent.exe moving to ssh-agent-orig.exe ... "
+               mv -f /usr/bin/ssh-agent.exe /usr/bin/ssh-agent-orig.exe
+               echo done
+               fi
+       else
         echo -n "  Moving ssh-agent.exe to ssh-agent-orig.exe ... "
         mv /usr/bin/ssh-agent.exe /usr/bin/ssh-agent-orig.exe
         echo done
@@ -21,6 +27,7 @@
     echo "No need to backup old ssh-agent - it doesn't exist. Hmmm."
 fi

+
 echo -n "Making ssh-agent point symlinkishly to charade ... "
 ln -s /usr/bin/charade.exe /usr/bin/ssh-agent.exe
 echo done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment