diff options
| author | Miles Bader | 2008-11-06 00:49:23 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-11-06 00:49:23 +0000 |
| commit | ed778fada51bffe8e6d69aefe9279f6f64f7b508 (patch) | |
| tree | 12aa50fb5c60108f75345a77b65d87872ac03505 | |
| parent | a2baa908022e3459e12eb4c7ce701f8391cf06c2 (diff) | |
| download | emacs-ed778fada51bffe8e6d69aefe9279f6f64f7b508.tar.gz emacs-ed778fada51bffe8e6d69aefe9279f6f64f7b508.zip | |
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1464
| -rw-r--r-- | lisp/gnus/ChangeLog | 18 | ||||
| -rw-r--r-- | lisp/gnus/auth-source.el | 55 | ||||
| -rw-r--r-- | lisp/gnus/starttls.el | 20 |
3 files changed, 75 insertions, 18 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index f311f4fdd30..82ace1a8ee9 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,21 @@ | |||
| 1 | 2008-11-04 Katsumi Yamaoka <yamaoka@jpl.org> | ||
| 2 | |||
| 3 | * starttls.el (starttls-any-program-available): Rewritten so it doesn't | ||
| 4 | require itself and to remove `with-no-warnings'. | ||
| 5 | |||
| 6 | 2008-11-03 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 7 | |||
| 8 | * starttls.el (starttls-any-program-available): Get the name of the | ||
| 9 | available TLS layer program. | ||
| 10 | (starttls-open-steam-gnutls, starttls-open-stream): Put port number as | ||
| 11 | well as the host name in the "opening" message. | ||
| 12 | |||
| 13 | * auth-source.el (auth-source-cache, auth-source-do-cache) | ||
| 14 | (auth-source-user-or-password): Cache passwords and logins by default, | ||
| 15 | allow override with `auth-source-do-cache'. | ||
| 16 | (auth-source-forget-user-or-password): Allow users to remove cache | ||
| 17 | entries if needed. | ||
| 18 | |||
| 1 | 2008-10-31 Teodor Zlatanov <tzz@lifelogs.com> | 19 | 2008-10-31 Teodor Zlatanov <tzz@lifelogs.com> |
| 2 | 20 | ||
| 3 | * ietf-drums.el (ietf-drums-remove-comments): Localize second | 21 | * ietf-drums.el (ietf-drums-remove-comments): Localize second |
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el index a19327e79fb..523c901f764 100644 --- a/lisp/gnus/auth-source.el +++ b/lisp/gnus/auth-source.el | |||
| @@ -91,6 +91,15 @@ | |||
| 91 | p))) | 91 | p))) |
| 92 | auth-source-protocols)) | 92 | auth-source-protocols)) |
| 93 | 93 | ||
| 94 | (defvar auth-source-cache (make-hash-table :test 'equal) | ||
| 95 | "Cache for auth-source data") | ||
| 96 | |||
| 97 | (defcustom auth-source-do-cache t | ||
| 98 | "Whether auth-source should cache information." | ||
| 99 | :group 'auth-source | ||
| 100 | :version "23.1" ;; No Gnus | ||
| 101 | :type `boolean) | ||
| 102 | |||
| 94 | (defcustom auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t)) | 103 | (defcustom auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t)) |
| 95 | "List of authentication sources. | 104 | "List of authentication sources. |
| 96 | 105 | ||
| @@ -150,26 +159,42 @@ Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t." | |||
| 150 | (unless fallback | 159 | (unless fallback |
| 151 | (auth-source-pick host protocol t))))) | 160 | (auth-source-pick host protocol t))))) |
| 152 | 161 | ||
| 162 | (defun auth-source-forget-user-or-password (mode host protocol) | ||
| 163 | (interactive "slogin/password: \nsHost: \nsProtocol: \n") ;for testing | ||
| 164 | (remhash (format "%s %s:%s" mode host protocol) auth-source-cache)) | ||
| 165 | |||
| 153 | (defun auth-source-user-or-password (mode host protocol) | 166 | (defun auth-source-user-or-password (mode host protocol) |
| 154 | "Find user or password (from the string MODE) matching HOST and PROTOCOL." | 167 | "Find user or password (from the string MODE) matching HOST and PROTOCOL." |
| 155 | (gnus-message 9 | 168 | (gnus-message 9 |
| 156 | "auth-source-user-or-password: get %s for %s (%s)" | 169 | "auth-source-user-or-password: get %s for %s (%s)" |
| 157 | mode host protocol) | 170 | mode host protocol) |
| 158 | (let (found) | 171 | (let* ((cname (format "%s %s:%s" mode host protocol)) |
| 159 | (dolist (choice (auth-source-pick host protocol)) | 172 | (found (gethash cname auth-source-cache))) |
| 160 | (setq found (netrc-machine-user-or-password | 173 | (if found |
| 161 | mode | 174 | (progn |
| 162 | (plist-get choice :source) | 175 | (gnus-message 9 |
| 163 | (list host) | 176 | "auth-source-user-or-password: cached %s=%s for %s (%s)" |
| 164 | (list (format "%s" protocol)) | 177 | mode |
| 165 | (auth-source-protocol-defaults protocol))) | 178 | ;; don't show the password |
| 166 | (when found | 179 | (if (equal mode "password") "SECRET" found) |
| 167 | (gnus-message 9 | 180 | host protocol) |
| 168 | "auth-source-user-or-password: found %s=%s for %s (%s)" | 181 | found) |
| 169 | mode | 182 | (dolist (choice (auth-source-pick host protocol)) |
| 170 | ;; don't show the password | 183 | (setq found (netrc-machine-user-or-password |
| 171 | (if (equal mode "password") "SECRET" found) | 184 | mode |
| 172 | host protocol) | 185 | (plist-get choice :source) |
| 186 | (list host) | ||
| 187 | (list (format "%s" protocol)) | ||
| 188 | (auth-source-protocol-defaults protocol))) | ||
| 189 | (when found | ||
| 190 | (gnus-message 9 | ||
| 191 | "auth-source-user-or-password: found %s=%s for %s (%s)" | ||
| 192 | mode | ||
| 193 | ;; don't show the password | ||
| 194 | (if (equal mode "password") "SECRET" found) | ||
| 195 | host protocol) | ||
| 196 | (when auth-source-do-cache | ||
| 197 | (puthash cname found auth-source-cache))) | ||
| 173 | (return found))))) | 198 | (return found))))) |
| 174 | 199 | ||
| 175 | (defun auth-source-protocol-defaults (protocol) | 200 | (defun auth-source-protocol-defaults (protocol) |
diff --git a/lisp/gnus/starttls.el b/lisp/gnus/starttls.el index 7aa13c26dcd..03d85226492 100644 --- a/lisp/gnus/starttls.el +++ b/lisp/gnus/starttls.el | |||
| @@ -241,7 +241,7 @@ handshake, or nil on failure." | |||
| 241 | 'process-kill-without-query))) | 241 | 'process-kill-without-query))) |
| 242 | 242 | ||
| 243 | (defun starttls-open-stream-gnutls (name buffer host port) | 243 | (defun starttls-open-stream-gnutls (name buffer host port) |
| 244 | (message "Opening STARTTLS connection to `%s'..." host) | 244 | (message "Opening STARTTLS connection to `%s:%s'..." host port) |
| 245 | (let* (done | 245 | (let* (done |
| 246 | (old-max (with-current-buffer buffer (point-max))) | 246 | (old-max (with-current-buffer buffer (point-max))) |
| 247 | (process-connection-type starttls-process-connection-type) | 247 | (process-connection-type starttls-process-connection-type) |
| @@ -266,8 +266,8 @@ handshake, or nil on failure." | |||
| 266 | (delete-region old-max done)) | 266 | (delete-region old-max done)) |
| 267 | (delete-process process) | 267 | (delete-process process) |
| 268 | (setq process nil)) | 268 | (setq process nil)) |
| 269 | (message "Opening STARTTLS connection to `%s'...%s" | 269 | (message "Opening STARTTLS connection to `%s:%s'...%s" |
| 270 | host (if done "done" "failed")) | 270 | host port (if done "done" "failed")) |
| 271 | process)) | 271 | process)) |
| 272 | 272 | ||
| 273 | (defun starttls-open-stream (name buffer host port) | 273 | (defun starttls-open-stream (name buffer host port) |
| @@ -287,6 +287,7 @@ If `starttls-use-gnutls' is nil, this may also be a service name, but | |||
| 287 | GNUTLS requires a port number." | 287 | GNUTLS requires a port number." |
| 288 | (if starttls-use-gnutls | 288 | (if starttls-use-gnutls |
| 289 | (starttls-open-stream-gnutls name buffer host port) | 289 | (starttls-open-stream-gnutls name buffer host port) |
| 290 | (message "Opening STARTTLS connection to `%s:%s'" host (format "%s" port)) | ||
| 290 | (let* ((process-connection-type starttls-process-connection-type) | 291 | (let* ((process-connection-type starttls-process-connection-type) |
| 291 | (process (apply #'start-process | 292 | (process (apply #'start-process |
| 292 | name buffer starttls-program | 293 | name buffer starttls-program |
| @@ -295,6 +296,19 @@ GNUTLS requires a port number." | |||
| 295 | (starttls-set-process-query-on-exit-flag process nil) | 296 | (starttls-set-process-query-on-exit-flag process nil) |
| 296 | process))) | 297 | process))) |
| 297 | 298 | ||
| 299 | (defun starttls-any-program-available () | ||
| 300 | (let ((program (if starttls-use-gnutls | ||
| 301 | starttls-gnutls-program | ||
| 302 | starttls-program))) | ||
| 303 | (condition-case () | ||
| 304 | (progn | ||
| 305 | (call-process program) | ||
| 306 | program) | ||
| 307 | (error (progn | ||
| 308 | (message "No STARTTLS program was available (tried '%s')" | ||
| 309 | program) | ||
| 310 | nil))))) | ||
| 311 | |||
| 298 | (provide 'starttls) | 312 | (provide 'starttls) |
| 299 | 313 | ||
| 300 | ;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 | 314 | ;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 |