? tramp.auth-source.patch Index: lisp/tramp.el =================================================================== RCS file: /sources/tramp/tramp/lisp/tramp.el,v retrieving revision 2.644 diff -c -r2.644 tramp.el *** lisp/tramp.el 13 May 2008 21:16:23 -0000 2.644 --- lisp/tramp.el 14 May 2008 17:23:43 -0000 *************** *** 87,92 **** --- 87,95 ---- (require 'shell) (require 'advice) + (eval-and-compile + (autoload 'auth-source-user-or-password "auth-source")) + ;; Requiring 'tramp-cache results in an endless loop. (autoload 'tramp-get-file-property "tramp-cache") (autoload 'tramp-set-file-property "tramp-cache") *************** *** 7191,7196 **** --- 7194,7200 ---- (defun tramp-read-passwd (proc &optional prompt) "Read a password from user (compat function). + Consults the auth-source package. Invokes `password-read' if available, `read-passwd' else." (let* ((key (tramp-make-tramp-file-name tramp-current-method tramp-current-user *************** *** 7200,7211 **** (with-current-buffer (process-buffer proc) (tramp-check-for-regexp proc tramp-password-prompt-regexp) (format "%s for %s " (capitalize (match-string 1)) key))))) ! (if (functionp 'password-read) ! (let ((password (funcall (symbol-function 'password-read) ! pw-prompt key))) ! (funcall (symbol-function 'password-cache-add) key password) ! password) ! (read-passwd pw-prompt)))) (defun tramp-clear-passwd (vec) "Clear password cache for connection related to VEC." --- 7204,7230 ---- (with-current-buffer (process-buffer proc) (tramp-check-for-regexp proc tramp-password-prompt-regexp) (format "%s for %s " (capitalize (match-string 1)) key))))) ! ! (or ! ;; see if auth-sources contains something useful, if it's bound ! (when (boundp 'auth-sources) ! (or ! ;; 1. try with Tramp's current method ! (auth-source-user-or-password ! "password" tramp-current-host tramp-current-method) ! ;; 2. try with Tramp's default method ! (auth-source-user-or-password ! "password" tramp-current-host tramp-default-method) ! ;; 3. hard-code the method to be "tramp" ! (auth-source-user-or-password ! "password" tramp-current-host "tramp"))) ! ;; 4. else, get the password interactively ! (if (functionp 'password-read) ! (let ((password (funcall (symbol-function 'password-read) ! pw-prompt key))) ! (funcall (symbol-function 'password-cache-add) key password) ! password) ! (read-passwd pw-prompt))))) (defun tramp-clear-passwd (vec) "Clear password cache for connection related to VEC."