]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge from gnus--devo--0
authorMiles Bader <miles@gnu.org>
Thu, 6 Nov 2008 00:49:23 +0000 (00:49 +0000)
committerMiles Bader <miles@gnu.org>
Thu, 6 Nov 2008 00:49:23 +0000 (00:49 +0000)
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1464

lisp/gnus/ChangeLog
lisp/gnus/auth-source.el
lisp/gnus/starttls.el

index f311f4fdd3080294561847f5e37a29a498fc2f7a..82ace1a8ee9ac86c8c3aa4d724e95b3fa6dbd8c9 100644 (file)
@@ -1,3 +1,21 @@
+2008-11-04  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * starttls.el (starttls-any-program-available): Rewritten so it doesn't
+       require itself and to remove `with-no-warnings'.
+
+2008-11-03  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * starttls.el (starttls-any-program-available): Get the name of the
+       available TLS layer program.
+       (starttls-open-steam-gnutls, starttls-open-stream): Put port number as
+       well as the host name in the "opening" message.
+
+       * auth-source.el (auth-source-cache, auth-source-do-cache)
+       (auth-source-user-or-password): Cache passwords and logins by default,
+       allow override with `auth-source-do-cache'.
+       (auth-source-forget-user-or-password): Allow users to remove cache
+       entries if needed.
+
 2008-10-31  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * ietf-drums.el (ietf-drums-remove-comments): Localize second
index a19327e79fb55fcb24be24f1e22547fb93ae63cf..523c901f76437fcd3a587f64da09a7c4e67124df 100644 (file)
                    p)))
          auth-source-protocols))
 
+(defvar auth-source-cache (make-hash-table :test 'equal)
+  "Cache for auth-source data")
+
+(defcustom auth-source-do-cache t
+  "Whether auth-source should cache information."
+  :group 'auth-source
+  :version "23.1" ;; No Gnus
+  :type `boolean)
+
 (defcustom auth-sources '((:source "~/.authinfo.gpg" :host t :protocol t))
   "List of authentication sources.
 
@@ -150,26 +159,42 @@ Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
       (unless fallback
        (auth-source-pick host protocol t)))))
 
+(defun auth-source-forget-user-or-password (mode host protocol)
+  (interactive "slogin/password: \nsHost: \nsProtocol: \n") ;for testing
+  (remhash (format "%s %s:%s" mode host protocol) auth-source-cache))
+
 (defun auth-source-user-or-password (mode host protocol)
   "Find user or password (from the string MODE) matching HOST and PROTOCOL."
   (gnus-message 9
                "auth-source-user-or-password: get %s for %s (%s)"
                mode host protocol)
-  (let (found)
-    (dolist (choice (auth-source-pick host protocol))
-      (setq found (netrc-machine-user-or-password
-                  mode
-                  (plist-get choice :source)
-                  (list host)
-                  (list (format "%s" protocol))
-                  (auth-source-protocol-defaults protocol)))
-      (when found
-       (gnus-message 9
-                     "auth-source-user-or-password: found %s=%s for %s (%s)"
-                     mode
-                     ;; don't show the password
-                     (if (equal mode "password") "SECRET" found)
-                     host protocol)
+  (let* ((cname (format "%s %s:%s" mode host protocol))
+        (found (gethash cname auth-source-cache)))
+    (if found
+       (progn
+         (gnus-message 9
+                       "auth-source-user-or-password: cached %s=%s for %s (%s)"
+                       mode
+                       ;; don't show the password
+                       (if (equal mode "password") "SECRET" found)
+                       host protocol)
+         found)
+      (dolist (choice (auth-source-pick host protocol))
+       (setq found (netrc-machine-user-or-password
+                    mode
+                    (plist-get choice :source)
+                    (list host)
+                    (list (format "%s" protocol))
+                    (auth-source-protocol-defaults protocol)))
+       (when found
+         (gnus-message 9
+                       "auth-source-user-or-password: found %s=%s for %s (%s)"
+                       mode
+                       ;; don't show the password
+                       (if (equal mode "password") "SECRET" found)
+                       host protocol)
+         (when auth-source-do-cache
+           (puthash cname found auth-source-cache)))
        (return found)))))
 
 (defun auth-source-protocol-defaults (protocol)
index 7aa13c26dcde251bd6a07609ca065dc3f66e2502..03d8522649282d06f6152120ded088fe5f6c3f39 100644 (file)
@@ -241,7 +241,7 @@ handshake, or nil on failure."
       'process-kill-without-query)))
 
 (defun starttls-open-stream-gnutls (name buffer host port)
-  (message "Opening STARTTLS connection to `%s'..." host)
+  (message "Opening STARTTLS connection to `%s:%s'..." host port)
   (let* (done
         (old-max (with-current-buffer buffer (point-max)))
         (process-connection-type starttls-process-connection-type)
@@ -266,8 +266,8 @@ handshake, or nil on failure."
          (delete-region old-max done))
       (delete-process process)
       (setq process nil))
-    (message "Opening STARTTLS connection to `%s'...%s"
-            host (if done "done" "failed"))
+    (message "Opening STARTTLS connection to `%s:%s'...%s"
+            host port (if done "done" "failed"))
     process))
 
 (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
 GNUTLS requires a port number."
   (if starttls-use-gnutls
       (starttls-open-stream-gnutls name buffer host port)
+    (message "Opening STARTTLS connection to `%s:%s'" host (format "%s" port))
     (let* ((process-connection-type starttls-process-connection-type)
           (process (apply #'start-process
                           name buffer starttls-program
@@ -295,6 +296,19 @@ GNUTLS requires a port number."
       (starttls-set-process-query-on-exit-flag process nil)
       process)))
 
+(defun starttls-any-program-available ()
+  (let ((program (if starttls-use-gnutls
+                    starttls-gnutls-program
+                  starttls-program)))
+    (condition-case ()
+       (progn
+         (call-process program)
+         program)
+      (error (progn
+              (message "No STARTTLS program was available (tried '%s')"
+                       program)
+              nil)))))
+
 (provide 'starttls)
 
 ;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297