]> git.eshelyaron.com Git - emacs.git/commitdiff
Adapt Tramp for auth-source
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 2 May 2018 16:12:48 +0000 (18:12 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 2 May 2018 16:12:48 +0000 (18:12 +0200)
* lisp/net/tramp.el (tramp-read-passwd): auth-source could return
cascaded functions.

lisp/net/tramp.el

index 5dda18f3a3bcde9d96d8b226c3d42c5de03285e2..e14a515b8bb052e64867ce9ba52c2c2d7ddcbea6 100644 (file)
@@ -4472,8 +4472,8 @@ Invokes `password-read' if available, `read-passwd' else."
 
     (unwind-protect
        (with-parsed-tramp-file-name key nil
-         (setq tramp-password-save-function nil)
-         (setq user
+         (setq tramp-password-save-function nil
+               user
                (or user (tramp-get-connection-property key "login-as" nil)))
          (prog1
              (or
@@ -4501,18 +4501,21 @@ Invokes `password-read' if available, `read-passwd' else."
                              :create t))
                            tramp-password-save-function
                            (plist-get auth-info :save-function)
-                           auth-passwd (plist-get auth-info :secret)
-                           auth-passwd (if (functionp auth-passwd)
-                                           (funcall auth-passwd)
-                                         auth-passwd))))
+                           auth-passwd (plist-get auth-info :secret)))
+                (while (functionp auth-passwd)
+                  (setq auth-passwd (funcall auth-passwd)))
+                auth-passwd)
 
               ;; Try the password cache.
-              (let ((password (password-read pw-prompt key)))
-                (setq tramp-password-save-function
-                      (lambda () (password-cache-add key password)))
-                password)
-              ;; Else, get the password interactively.
+              (progn
+                (setq auth-passwd (password-read pw-prompt key)
+                      tramp-password-save-function
+                      (lambda () (password-cache-add key auth-passwd)))
+                auth-passwd)
+
+              ;; Else, get the password interactively w/o cache.
               (read-passwd pw-prompt))
+
            (tramp-set-connection-property v "first-password-request" nil)))
 
       ;; Reenable the timers.