aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/auth-source.el
diff options
context:
space:
mode:
authorMichael Albinus2018-04-23 10:16:06 +0200
committerMichael Albinus2018-04-23 10:16:06 +0200
commit0ecc10a7771bf1f62d15b2e6c747bee9f7a557ff (patch)
tree7547eb4f8b8282b88d811189b26fa6dc42d06d77 /lisp/auth-source.el
parente7044d294c1b1779b3124b27ba0f09b22b64df20 (diff)
downloademacs-0ecc10a7771bf1f62d15b2e6c747bee9f7a557ff.tar.gz
emacs-0ecc10a7771bf1f62d15b2e6c747bee9f7a557ff.zip
Let Tramp save passwords
* lisp/auth-source.el (auth-source-secrets-saver): New defun. (auth-source-secrets-create): Use it. * lisp/net/secrets.el (secrets-struct-secret-content-type): (secrets-create-item): Do not hard-code :xdg:schema. * lisp/net/tramp.el (tramp-password-save-function): New defvar. (tramp-read-passwd): Set it properly. (tramp-process-actions): * lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): Save password. * lisp/net/tramp-cmds.el (tramp-bug): Don't report `tramp-password-save-function'. * test/lisp/net/secrets-tests.el (secrets-test03-items): Extend test with another :xdg:schema.
Diffstat (limited to 'lisp/auth-source.el')
-rw-r--r--lisp/auth-source.el37
1 files changed, 36 insertions, 1 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index a2ed47a0d45..df3622a412a 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1732,10 +1732,45 @@ authentication tokens:
1732 (item (plist-get artificial :label)) 1732 (item (plist-get artificial :label))
1733 (secret (plist-get artificial :secret)) 1733 (secret (plist-get artificial :secret))
1734 (secret (if (functionp secret) (funcall secret) secret))) 1734 (secret (if (functionp secret) (funcall secret) secret)))
1735 (lambda () (apply 'secrets-create-item collection item secret args)))) 1735 (lambda ()
1736 (apply 'auth-source-secrets-saver collection item secret args))))
1736 1737
1737 (list artificial))) 1738 (list artificial)))
1738 1739
1740(defun auth-source-secrets-saver (collection item secret args)
1741 "Wrapper around `secrets-create-item', prompting along the way.
1742Respects `auth-source-save-behavior'."
1743 (let ((prompt (format "Save auth info to secrets collection %s? " collection))
1744 (done (not (eq auth-source-save-behavior 'ask)))
1745 (bufname "*auth-source Help*")
1746 doit k)
1747 (while (not done)
1748 (setq k (auth-source-read-char-choice prompt '(?y ?n ?N ??)))
1749 (cl-case k
1750 (?y (setq done t doit t))
1751 (?? (save-excursion
1752 (with-output-to-temp-buffer bufname
1753 (princ
1754 (concat "(y)es, save\n"
1755 "(n)o but use the info\n"
1756 "(N)o and don't ask to save again\n"
1757 "(?) for help as you can see.\n"))
1758 ;; Why? Doesn't with-output-to-temp-buffer already do
1759 ;; the exact same thing anyway? --Stef
1760 (set-buffer standard-output)
1761 (help-mode))))
1762 (?n (setq done t doit nil))
1763 (?N (setq done t doit nil)
1764 (customize-save-variable 'auth-source-save-behavior nil))
1765 (t nil)))
1766
1767 (when doit
1768 (progn
1769 (auth-source-do-debug
1770 "secrets-create-item: wrote 1 new item to %s" collection)
1771 (message "Saved new authentication information to %s" collection)
1772 (apply 'secrets-create-item collection item secret args)))))
1773
1739;;; Backend specific parsing: Mac OS Keychain (using /usr/bin/security) backend 1774;;; Backend specific parsing: Mac OS Keychain (using /usr/bin/security) backend
1740 1775
1741(cl-defun auth-source-macos-keychain-search (&rest spec 1776(cl-defun auth-source-macos-keychain-search (&rest spec