diff options
| author | Gnus developers | 2011-02-17 23:46:18 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2011-02-17 23:46:18 +0000 |
| commit | 7ba93e94392a7a5ffe0c3c2d87f04f26b6054026 (patch) | |
| tree | c4f5121505fe680429e83cfcee51690aebba28c3 | |
| parent | 2a095cec7ae4b3e076bcb0aba542248c3660e158 (diff) | |
| download | emacs-7ba93e94392a7a5ffe0c3c2d87f04f26b6054026.tar.gz emacs-7ba93e94392a7a5ffe0c3c2d87f04f26b6054026.zip | |
Merge chagnes made in Gnus trunk.
auth.texi (GnuPG and EasyPG Assistant Configuration): Mention the default now is to have two files in `auth-sources'.
nnimap.el (nnimap-open-connection-1): Delete duplicate server names when getting credentials.
gnus-util.el (gnus-delete-duplicates): New function.
nnimap.el (nnimap-credentials): Instead of picking the first port as a creation default, pass the whole port list down. It will be completed.
auth-source.el (auth-source-search): Updated docs to talk about multiple creation choices.
(auth-source-netrc-create): Accept a list as a value (from the search parameters) and do completion on that list. Keep a separate netrc line with the password obscured for showing the user.
nnimap.el (nnimap-open-connection-1): Make the `nnimap-address' the first choice to `auth-source-search' so it will be used for entry creation instead of the server's Gnus-specific name.
(nnimap-credentials): Rely on the auth-source library to select which port is actually wanted in the new netrc entry, so don't override `auth-source-creation-defaults'.
| -rw-r--r-- | doc/misc/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/misc/auth.texi | 4 | ||||
| -rw-r--r-- | lisp/gnus/ChangeLog | 24 | ||||
| -rw-r--r-- | lisp/gnus/auth-source.el | 54 | ||||
| -rw-r--r-- | lisp/gnus/gnus-util.el | 9 | ||||
| -rw-r--r-- | lisp/gnus/nnimap.el | 10 |
6 files changed, 81 insertions, 22 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 9a292c03c8d..c075f1785d3 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | * auth.texi (Help for users): Use :port instead of :protocol for all | 3 | * auth.texi (Help for users): Use :port instead of :protocol for all |
| 4 | auth-source docs. | 4 | auth-source docs. |
| 5 | (GnuPG and EasyPG Assistant Configuration): Mention the default now is | ||
| 6 | to have two files in `auth-sources'. | ||
| 5 | 7 | ||
| 6 | 2011-02-16 Glenn Morris <rgm@gnu.org> | 8 | 2011-02-16 Glenn Morris <rgm@gnu.org> |
| 7 | 9 | ||
diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi index 0e19bce0b9f..67f5b52b694 100644 --- a/doc/misc/auth.texi +++ b/doc/misc/auth.texi | |||
| @@ -262,7 +262,9 @@ TODO: how to include docstring? | |||
| 262 | @appendix GnuPG and EasyPG Assistant Configuration | 262 | @appendix GnuPG and EasyPG Assistant Configuration |
| 263 | 263 | ||
| 264 | If you don't customize @code{auth-sources}, the auth-source library | 264 | If you don't customize @code{auth-sources}, the auth-source library |
| 265 | reads @code{~/.authinfo.gpg}, which is a GnuPG encrypted file. | 265 | reads @code{~/.authinfo.gpg}, which is a GnuPG encrypted file. Then |
| 266 | it will check @code{~/.authinfo} but it's not recommended to use such | ||
| 267 | an unencrypted file. | ||
| 266 | 268 | ||
| 267 | In Emacs 23 or later there is an option @code{auto-encryption-mode} to | 269 | In Emacs 23 or later there is an option @code{auto-encryption-mode} to |
| 268 | automatically decrypt @code{*.gpg} files. It is enabled by default. | 270 | automatically decrypt @code{*.gpg} files. It is enabled by default. |
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index cc405410db9..7b6aa86ac06 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,5 +1,29 @@ | |||
| 1 | 2011-02-17 Lars Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * nnimap.el (nnimap-open-connection-1): Delete duplicate server names | ||
| 4 | when getting credentials. | ||
| 5 | |||
| 6 | * gnus-util.el (gnus-delete-duplicates): New function. | ||
| 7 | |||
| 1 | 2011-02-17 Teodor Zlatanov <tzz@lifelogs.com> | 8 | 2011-02-17 Teodor Zlatanov <tzz@lifelogs.com> |
| 2 | 9 | ||
| 10 | * nnimap.el (nnimap-credentials): Instead of picking the first port as | ||
| 11 | a creation default, pass the whole port list down. It will be | ||
| 12 | completed. | ||
| 13 | |||
| 14 | * auth-source.el (auth-source-search): Updated docs to talk about | ||
| 15 | multiple creation choices. | ||
| 16 | (auth-source-netrc-create): Accept a list as a value (from the search | ||
| 17 | parameters) and do completion on that list. Keep a separate netrc line | ||
| 18 | with the password obscured for showing the user. | ||
| 19 | |||
| 20 | * nnimap.el (nnimap-open-connection-1): Make the `nnimap-address' the | ||
| 21 | first choice to `auth-source-search' so it will be used for entry | ||
| 22 | creation instead of the server's Gnus-specific name. | ||
| 23 | (nnimap-credentials): Rely on the auth-source library to select which | ||
| 24 | port is actually wanted in the new netrc entry, so don't override | ||
| 25 | `auth-source-creation-defaults'. | ||
| 26 | |||
| 3 | * auth-source.el (auth-source-netrc-parse): Use :port instead of | 27 | * auth-source.el (auth-source-netrc-parse): Use :port instead of |
| 4 | :protocol and accept a missing user, host, or port as a wildcard match. | 28 | :protocol and accept a missing user, host, or port as a wildcard match. |
| 5 | (auth-source-debug): Default to off. | 29 | (auth-source-debug): Default to off. |
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el index 29a3ca06707..338dd01e77b 100644 --- a/lisp/gnus/auth-source.el +++ b/lisp/gnus/auth-source.el | |||
| @@ -453,8 +453,8 @@ which says: | |||
| 453 | search to find only entries that have P set to 'pppp'.\" | 453 | search to find only entries that have P set to 'pppp'.\" |
| 454 | 454 | ||
| 455 | When multiple values are specified in the search parameter, the | 455 | When multiple values are specified in the search parameter, the |
| 456 | first one is used for creation. So :host (X Y Z) would create a | 456 | user is prompted for which one. So :host (X Y Z) would ask the |
| 457 | token for host X, for instance. | 457 | user to choose between X, Y, and Z. |
| 458 | 458 | ||
| 459 | This creation can fail if the search was not specific enough to | 459 | This creation can fail if the search was not specific enough to |
| 460 | create a new token (it's up to the backend to decide that). You | 460 | create a new token (it's up to the backend to decide that). You |
| @@ -851,6 +851,7 @@ See `auth-source-search' for details on SPEC." | |||
| 851 | (required (append base-required create-extra)) | 851 | (required (append base-required create-extra)) |
| 852 | (file (oref backend source)) | 852 | (file (oref backend source)) |
| 853 | (add "") | 853 | (add "") |
| 854 | (show "") | ||
| 854 | ;; `valist' is an alist | 855 | ;; `valist' is an alist |
| 855 | valist | 856 | valist |
| 856 | ;; `artificial' will be returned if no creation is needed | 857 | ;; `artificial' will be returned if no creation is needed |
| @@ -858,12 +859,16 @@ See `auth-source-search' for details on SPEC." | |||
| 858 | 859 | ||
| 859 | ;; only for base required elements (defined as function parameters): | 860 | ;; only for base required elements (defined as function parameters): |
| 860 | ;; fill in the valist with whatever data we may have from the search | 861 | ;; fill in the valist with whatever data we may have from the search |
| 861 | ;; we take the first value if it's a list, the whole value otherwise | 862 | ;; we complete the first value if it's a list and use the value otherwise |
| 862 | (dolist (br base-required) | 863 | (dolist (br base-required) |
| 863 | (when (symbol-value br) | 864 | (when (symbol-value br) |
| 864 | (aput 'valist br (if (listp (symbol-value br)) | 865 | (let ((br-choice (cond |
| 865 | (nth 0 (symbol-value br)) | 866 | ;; all-accepting choice (predicate is t) |
| 866 | (symbol-value br))))) | 867 | ((eq t (symbol-value br)) nil) |
| 868 | ;; just the value otherwise | ||
| 869 | (t (symbol-value br))))) | ||
| 870 | (when br-choice | ||
| 871 | (aput 'valist br br-choice))))) | ||
| 867 | 872 | ||
| 868 | ;; for extra required elements, see if the spec includes a value for them | 873 | ;; for extra required elements, see if the spec includes a value for them |
| 869 | (dolist (er create-extra) | 874 | (dolist (er create-extra) |
| @@ -894,6 +899,8 @@ See `auth-source-search' for details on SPEC." | |||
| 894 | (user-value (aget valist 'user)) | 899 | (user-value (aget valist 'user)) |
| 895 | (host-value (aget valist 'host)) | 900 | (host-value (aget valist 'host)) |
| 896 | (port-value (aget valist 'port)) | 901 | (port-value (aget valist 'port)) |
| 902 | ;; note this handles lists by just printing them | ||
| 903 | ;; later we allow the user to use completing-read to pick | ||
| 897 | (info-so-far (concat (if user-value | 904 | (info-so-far (concat (if user-value |
| 898 | (format "%s@" user-value) | 905 | (format "%s@" user-value) |
| 899 | "[USER?]") | 906 | "[USER?]") |
| @@ -921,6 +928,16 @@ See `auth-source-search' for details on SPEC." | |||
| 921 | (format "Enter %s for %s%s: " | 928 | (format "Enter %s for %s%s: " |
| 922 | r info-so-far default-string) | 929 | r info-so-far default-string) |
| 923 | nil nil default)) | 930 | nil nil default)) |
| 931 | ((listp data) | ||
| 932 | (completing-read | ||
| 933 | (format "Enter %s for %s (TAB to see the choices): " | ||
| 934 | r info-so-far) | ||
| 935 | data | ||
| 936 | nil ; no predicate | ||
| 937 | t ; require a match | ||
| 938 | ;; note the default is nil, but if the user | ||
| 939 | ;; hits RET we'll get "", which is handled OK later | ||
| 940 | nil)) | ||
| 924 | (t data)))) | 941 | (t data)))) |
| 925 | 942 | ||
| 926 | (when data | 943 | (when data |
| @@ -934,20 +951,25 @@ See `auth-source-search' for details on SPEC." | |||
| 934 | ;; when r is not an empty string... | 951 | ;; when r is not an empty string... |
| 935 | (when (and (stringp data) | 952 | (when (and (stringp data) |
| 936 | (< 0 (length data))) | 953 | (< 0 (length data))) |
| 937 | ;; append the key (the symbol name of r) and the value in r | 954 | (let ((printer (lambda (hide) |
| 938 | (setq add (concat add | 955 | ;; append the key (the symbol name of r) |
| 939 | (format "%s%s %S" | 956 | ;; and the value in r |
| 940 | ;; prepend a space | 957 | (format "%s%s %S" |
| 941 | (if (zerop (length add)) "" " ") | 958 | ;; prepend a space |
| 942 | ;; remap auth-source tokens to netrc | 959 | (if (zerop (length add)) "" " ") |
| 943 | (case r | 960 | ;; remap auth-source tokens to netrc |
| 961 | (case r | ||
| 944 | ('user "login") | 962 | ('user "login") |
| 945 | ('host "machine") | 963 | ('host "machine") |
| 946 | ('secret "password") | 964 | ('secret "password") |
| 947 | ('port "port") ; redundant but clearer | 965 | ('port "port") ; redundant but clearer |
| 948 | (t (symbol-name r))) | 966 | (t (symbol-name r))) |
| 949 | ;; the value will be printed in %S format | 967 | ;; the value will be printed in %S format |
| 950 | data)))))) | 968 | (if (and hide (eq r 'secret)) |
| 969 | "HIDDEN_SECRET" | ||
| 970 | data))))) | ||
| 971 | (setq add (concat add (funcall printer nil))) | ||
| 972 | (setq show (concat show (funcall printer t))))))) | ||
| 951 | 973 | ||
| 952 | (with-temp-buffer | 974 | (with-temp-buffer |
| 953 | (when (file-exists-p file) | 975 | (when (file-exists-p file) |
| @@ -964,7 +986,7 @@ See `auth-source-search' for details on SPEC." | |||
| 964 | (goto-char (point-max)) | 986 | (goto-char (point-max)) |
| 965 | 987 | ||
| 966 | ;; ask AFTER we've successfully opened the file | 988 | ;; ask AFTER we've successfully opened the file |
| 967 | (if (y-or-n-p (format "Add to file %s: line [%s]" file add)) | 989 | (if (y-or-n-p (format "Add to file %s: line [%s]" file show)) |
| 968 | (progn | 990 | (progn |
| 969 | (unless (bolp) | 991 | (unless (bolp) |
| 970 | (insert "\n")) | 992 | (insert "\n")) |
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index 67c49096b92..42dbd5948cf 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el | |||
| @@ -871,6 +871,15 @@ Bind `print-quoted' and `print-readably' to t, and `print-length' and | |||
| 871 | (when (file-exists-p file) | 871 | (when (file-exists-p file) |
| 872 | (delete-file file))) | 872 | (delete-file file))) |
| 873 | 873 | ||
| 874 | (defun gnus-delete-duplicates (list) | ||
| 875 | "Remove duplicate entries from LIST." | ||
| 876 | (let ((result nil)) | ||
| 877 | (while list | ||
| 878 | (unless (member (car list) result) | ||
| 879 | (push (car list) result)) | ||
| 880 | (pop list)) | ||
| 881 | (nreverse result))) | ||
| 882 | |||
| 874 | (defun gnus-delete-directory (directory) | 883 | (defun gnus-delete-directory (directory) |
| 875 | "Delete files in DIRECTORY. Subdirectories remain. | 884 | "Delete files in DIRECTORY. Subdirectories remain. |
| 876 | If there's no subdirectory, delete DIRECTORY as well." | 885 | If there's no subdirectory, delete DIRECTORY as well." |
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index fc8873ff565..7f8ecc1710f 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el | |||
| @@ -277,8 +277,7 @@ textual parts.") | |||
| 277 | (current-buffer))) | 277 | (current-buffer))) |
| 278 | 278 | ||
| 279 | (defun nnimap-credentials (address ports) | 279 | (defun nnimap-credentials (address ports) |
| 280 | (let* ((auth-source-creation-defaults `((port . ,(nth 0 ports)))) | 280 | (let* ((found (nth 0 (auth-source-search :max 1 |
| 281 | (found (nth 0 (auth-source-search :max 1 | ||
| 282 | :host address | 281 | :host address |
| 283 | :port ports | 282 | :port ports |
| 284 | :create t))) | 283 | :create t))) |
| @@ -385,9 +384,10 @@ textual parts.") | |||
| 385 | ;; Look for the credentials based on | 384 | ;; Look for the credentials based on |
| 386 | ;; the virtual server name and the address | 385 | ;; the virtual server name and the address |
| 387 | (nnimap-credentials | 386 | (nnimap-credentials |
| 388 | (list | 387 | (gnus-delete-duplicates |
| 389 | (nnoo-current-server 'nnimap) | 388 | (list |
| 390 | nnimap-address) | 389 | nnimap-address |
| 390 | (nnoo-current-server 'nnimap))) | ||
| 391 | ports)))) | 391 | ports)))) |
| 392 | (setq nnimap-object nil) | 392 | (setq nnimap-object nil) |
| 393 | (let ((nnimap-inhibit-logging t)) | 393 | (let ((nnimap-inhibit-logging t)) |