From 5615d63facc03d694c9195eb8fddbb9939ae1694 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 15 May 2008 21:06:59 +0000 Subject: [PATCH] * 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'. --- lisp/ChangeLog | 9 +++++++++ lisp/net/tramp.el | 31 ++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bec5c389e1c..75f578eb51c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2008-05-15 Michael Albinus + + * net/tramp.el (tramp-file-name-for-operation): Add `make-temp-name'. + +2008-05-15 Teodor Zlatanov + + * net/tramp.el: Load auth-source library. + (tramp-read-passwd): Use it for password, not login. + 2008-05-15 Shigeru Fukaya * ses.el (ses-goto-print): Use move-to-column rather than diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 9894c27a839..723eba0a93b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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 @@ ARGS are the arguments OPERATION has been called with." '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 @@ ALIST is of the form ((FROM . TO) ...)." (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 @@ Invokes `password-read' if available, `read-passwd' else." (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." -- 2.39.2