On Thu, 26 May 2011 09:09:40 -0500 Ted Zlatanov <[email protected]> wrote: 

TZ> OK.  Is the Git CLI interaction in `magit-password' the only place I
TZ> need to fix?  I don't think Magit does anything else with passwords,
TZ> right?  See below about askpass...

Assuming so, here's an untested patch as an initial idea.  It
distinguishes between SSH key passphrases and actual passwords.

For older versions of auth-source.el we'll use the
`auth-source-user-or-password' function.  But please check the general
idea of this patch and see if it makes sense.  Also check the HTTP
auth--without the origin URL I don't know what I'm looking up...

Thanks
Ted

68a69,70
> (require 'auth-source nil t)
> 
1365,1370c1367,1391
<   (when (or (string-match "^Enter passphrase for key '\\\(.*\\\)': $" string)
< 	    (string-match "^\\\(.*\\\)'s password:" string))
<     (process-send-string proc
<                          (concat (read-passwd
<                                   (format "Password for '%s': " (match-string 1 string))
<                                   nil) "\n"))))
---
>   (cond
>    ((or (string-match "^Enter passphrase for \\(key\\) '\\\(.*\\\)': $" string)
>         (string-match "^\\\(.*\\\)'s password:" string))
>     (let* ((key (equal "key" (match-string 1 string)))
>            (matched (if key (match-string 2 string) (match-string 1 string)))
>            (found (and (fboundp 'auth-source-search)
>                        (nth 0 (auth-source-search :max 1
>                                                   :host matched
>                                                   :port (if key "ssh-key" "git")
>                                                   :user user
>                                                   :require '(:user :secret)
>                                                   :create nil)))))
>       (process-send-string proc
>                            (concat (or
>                                     (let ((secret (plist-get found :secret)))
>                                       (if (functionp secret)
>                                           (funcall secret)
>                                         secret))
>                                     (read-passwd
>                                      (format "Password for '%s': " matched)
>                                      nil))
>                                    "\n"))))
>    ((or (string-match "^\\(Username\\): $" string)
>         (string-match "^\\(Password\\): $" string))
>     (message "HTTP auth not implemented: we don't know the origin URL"))))

Reply via email to