Mercurial > emacs
changeset 95025:bdaea36b81dd
* net/tramp.el: Load auth-source library.
(tramp-read-passwd): Use it for password, not login.
(tramp-file-name-for-operation): Add `make-temp-name'.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Thu, 15 May 2008 21:06:00 +0000 |
parents | 7573004f2849 |
children | d3150b7dc91a |
files | lisp/net/tramp.el |
diffstat | 1 files changed, 24 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/net/tramp.el Thu May 15 19:29:38 2008 +0000 +++ b/lisp/net/tramp.el Thu May 15 21:06:00 2008 +0000 @@ -87,6 +87,10 @@ (require 'shell) (require 'advice) +(if (featurep 'xemacs) + (load "auth-source" 'noerror) + (require 'auth-source nil 'noerror)) + ;; Requiring 'tramp-cache results in an endless loop. (autoload 'tramp-get-file-property "tramp-cache") (autoload 'tramp-set-file-property "tramp-cache") @@ -4425,7 +4429,7 @@ 'dired-file-modtime 'dired-make-compressed-filename 'dired-recursive-delete-directory 'dired-set-file-modtime 'dired-shell-unhandle-file-name 'dired-uucode-file - 'insert-file-contents-literally 'recover-file + 'insert-file-contents-literally 'make-temp-name 'recover-file 'vm-imap-check-mail 'vm-pop-check-mail 'vm-spool-check-mail)) (if (file-name-absolute-p (nth 0 args)) (nth 0 args) @@ -7200,6 +7204,7 @@ (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 @@ -7209,12 +7214,24 @@ (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)))) + + (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. hard-code the method to be "tramp" + (auth-source-user-or-password + "password" tramp-current-host "tramp"))) + ;; 3. 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."