Kaynağa Gözat

Bind SSH Agent to socket with PID in name to allow more than one.

master
Chris McCormick 8 yıl önce
ebeveyn
işleme
8dd2238425
1 değiştirilmiş dosya ile 9 ekleme ve 1 silme
  1. 9
    1
      gitnonymous

+ 9
- 1
gitnonymous Dosyayı Görüntüle

52
     configfile="${rootdir}/config"
52
     configfile="${rootdir}/config"
53
     sshdir="${rootdir}/ssh"
53
     sshdir="${rootdir}/ssh"
54
     oldenvfile="${rootdir}/previous-environment"
54
     oldenvfile="${rootdir}/previous-environment"
55
+    sshagentsocket="${sshdir}/.ssh-agent-$$"
55
     
56
     
56
     if [ "$_GITNONYMOUS" != "" ]
57
     if [ "$_GITNONYMOUS" != "" ]
57
     # toggle everything off again
58
     # toggle everything off again
79
       # add our custom local SSH key (make the key with ./make-anonymous-key)
80
       # add our custom local SSH key (make the key with ./make-anonymous-key)
80
       if [ -f ${sshdir}/id_rsa ]
81
       if [ -f ${sshdir}/id_rsa ]
81
       then
82
       then
83
+        # if a stale socket already exists then throw an error
84
+        if [ -f "${sshagentsocket}" ]
85
+        then
86
+          gitnonymous_error "Stale SSH agent socket '${sshagentsocket}' exists."
87
+          gitnonymous_error "You can probably delete it safely and try again."
88
+          return 2
89
+        fi
82
         # start a new SSH agent just for this session
90
         # start a new SSH agent just for this session
83
-        eval $(ssh-agent -a "${sshdir}/.ssh-agent")
91
+        eval $(ssh-agent -a "${sshagentsocket}")
84
         # add the key
92
         # add the key
85
         ssh-add ${sshdir}/id_rsa
93
         ssh-add ${sshdir}/id_rsa
86
       else
94
       else

Loading…
İptal
Kaydet