[gnus git] branch tzz-auth-source-rewrite updated: =5= Merge branch 'master' of https://git.gnus.org/gnus into tzz-auth-source-rewrite ; Add caching through password-cache. ; Disable the async code for now, since it doesn't work for all users. ; message: make message-options really buffer local ; shr: add support for text attribute in body

Lars Magne Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  bb14e42650df76c01ba8ea09bc341e7abae239ba (commit)
       via  90e4c6ac159c751bb54c5d2053d5f3aa71b78640 (commit)
       via  8eb5f1cde674860ba1a05c8754e45dbadc137ca5 (commit)
       via  d7f2cb176d4c7dfad075e3914bdde41553ef5a9f (commit)
       via  63f4303602489f15cc8bf1c9f1696e18436999dd (commit)
      from  8894cb17aa25f5de7672f93fd52f4731f42ed9e0 (commit)


- Log -----------------------------------------------------------------
commit bb14e42650df76c01ba8ea09bc341e7abae239ba
Merge: 90e4c6a 8eb5f1c
Author: Ted Zlatanov <[email protected]>
Date:   Wed Feb 9 15:34:12 2011 -0600

    Merge branch 'master' of https://git.gnus.org/gnus into tzz-auth-source-rewrite
    
    Conflicts:
    	lisp/ChangeLog

diff --cc lisp/ChangeLog
index 31975c1,0a90892..ec7910e
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@@ -1,52 -1,20 +1,65 @@@
 +2011-02-09  Teodor Zlatanov  <[email protected]>
 +
 +	* nnimap.el: Autoload `auth-source-forget+'.
 +	(nnimap-open-connection-1): Use it if the connection fails.
 +
 +	* auth-source.el: Require `password-cache'.
 +	(auth-source-hide-passwords, auth-source-cache): Remove and mark
 +	obsolete.
 +	(auth-source-magic): Marker for `password-cache' keys.
 +	(auth-source-do-cache): Update docstring.
 +	(auth-source-search): Use and check cache.
 +	(auth-source-forget-all-cached, auth-source-remember)
 +	(auth-source-recall, auth-source-forget, auth-source-forget+)
 +	(auth-source-specmatchp): Caching support functions.
 +	(auth-source-forget-user-or-password, auth-source-forget-all-cached):
 +	Remove and obsolete.
 +	(auth-source-user-or-password): Remove caching to further discourage
 +	using it.  Always hide passwords.
 +
 +	* password-cache.el (password-cache-remove): Accept secrets that are
 +	not strings.
 +
+ 2011-02-09  Lars Ingebrigtsen  <[email protected]>
+ 
+ 	* nntp.el (nntp-retrieve-group-data-early-disabled): Disable the async
+ 	code for now, since it doesn't work for all users.
+ 
+ 2011-02-09  Julien Danjou  <[email protected]>
+ 
+ 	* message.el (message-options): Make message-options really buffer
+ 	local.
+ 
 +2011-02-08  Teodor Zlatanov  <[email protected]>
 +
 +	* mail-source.el: Autoload `auth-source-search'.
 +	(mail-source-keyword-map): Note order matters.
 +	(mail-source-set-1): Get all the mail-source source values and
 +	defaults and search auth-source on those if needed.  This can all
 +	probably be simplified.
 +
 +	* nnimap.el: Autoload `auth-source-search'.
 +	(nnimap-credentials): Use it.
 +	(nnimap-open-connection-1): Ask for the virtual server and physical
 +	address in one shot.
 +
 +	* nntp.el: Autoload `auth-source-search'.
 +	(nntp-send-authinfo): Use it.  Note TODO.
 +
  2011-02-08  Julien Danjou  <[email protected]>
  
+ 	* shr.el (shr-tag-body): Add support for text attribute in body
+ 	markups.
+ 
  	* message.el (message-options): Make message-options a local variable.
  
 +2011-02-07  Teodor Zlatanov  <[email protected]>
 +
 +	* auth-source.el (auth-source-secrets-search)
 +	(auth-source-user-or-password): Use `append' instead of `nconc'.
 +	(auth-source-user-or-password): Build return list better and protect
 +	against nil :secret.
 +
  2011-02-07  Lars Ingebrigtsen  <[email protected]>
  
  	* nnimap.el (nnimap-update-info): Refactor slightly.

commit 90e4c6ac159c751bb54c5d2053d5f3aa71b78640
Author: Ted Zlatanov <[email protected]>
Date:   Wed Feb 9 15:32:55 2011 -0600

    Add caching through password-cache.
    
    * password-cache.el (password-cache-remove): Accept secrets that are
    not strings.
    
    * auth-source.el: Require `password-cache'.
    (auth-source-hide-passwords, auth-source-cache): Remove and mark
    obsolete.
    (auth-source-magic): Marker for `password-cache' keys.
    (auth-source-do-cache): Update docstring.
    (auth-source-search): Use and check cache.
    (auth-source-forget-all-cached, auth-source-remember)
    (auth-source-recall, auth-source-forget, auth-source-forget+)
    (auth-source-specmatchp): Caching support functions.
    (auth-source-forget-user-or-password, auth-source-forget-all-cached):
    Remove and obsolete.
    (auth-source-user-or-password): Remove caching to further discourage
    using it.  Always hide passwords.
    
    * nnimap.el: Autoload `auth-source-forget+'.
    (nnimap-open-connection-1): Use it if the connection fails.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 31d890d..31975c1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,25 @@
+2011-02-09  Teodor Zlatanov  <[email protected]>
+
+	* nnimap.el: Autoload `auth-source-forget+'.
+	(nnimap-open-connection-1): Use it if the connection fails.
+
+	* auth-source.el: Require `password-cache'.
+	(auth-source-hide-passwords, auth-source-cache): Remove and mark
+	obsolete.
+	(auth-source-magic): Marker for `password-cache' keys.
+	(auth-source-do-cache): Update docstring.
+	(auth-source-search): Use and check cache.
+	(auth-source-forget-all-cached, auth-source-remember)
+	(auth-source-recall, auth-source-forget, auth-source-forget+)
+	(auth-source-specmatchp): Caching support functions.
+	(auth-source-forget-user-or-password, auth-source-forget-all-cached):
+	Remove and obsolete.
+	(auth-source-user-or-password): Remove caching to further discourage
+	using it.  Always hide passwords.
+
+	* password-cache.el (password-cache-remove): Accept secrets that are
+	not strings.
+
 2011-02-08  Teodor Zlatanov  <[email protected]>
 
 	* mail-source.el: Autoload `auth-source-search'.
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 7ef6f97..b7a7b41 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -39,6 +39,7 @@
 
 ;;; Code:
 
+(require 'password-cache)
 (require 'gnus-util)
 (require 'netrc)
 (require 'assoc)
@@ -124,11 +125,12 @@
 (defvar auth-source-creation-defaults nil
   "Defaults for creating token values.  Usually let-bound.")
 
-(defvar auth-source-cache (make-hash-table :test 'equal)
-  "Cache for auth-source data")
+(make-obsolete 'auth-source-hide-passwords nil "Emacs 24.1")
+
+(defvar auth-source-magic "auth-source-magic ")
 
 (defcustom auth-source-do-cache t
-  "Whether auth-source should cache information."
+  "Whether auth-source should cache information with `password-cache'."
   :group 'auth-source
   :version "23.2" ;; No Gnus
   :type `boolean)
@@ -151,13 +153,6 @@ If the value is a function, debug messages are logged by calling
           (function :tag "Function that takes arguments like `message'")
           (const :tag "Don't log anything" nil)))
 
-(defcustom auth-source-hide-passwords t
-  "Whether auth-source should hide passwords in log messages.
-Only relevant if `auth-source-debug' is not nil."
-  :group 'auth-source
-  :version "23.2" ;; No Gnus
-  :type `boolean)
-
 (defcustom auth-sources '("~/.authinfo.gpg" "~/.authinfo")
   "List of authentication sources.
 
@@ -478,8 +473,16 @@ must call it to obtain the actual value."
          (keys (loop for i below (length spec) by 2
                      unless (memq (nth i spec) ignored-keys)
                      collect (nth i spec)))
-         filtered-backends accessor-key found-here found goal)
-    (assert (or (eq t create) (listp create)) t
+         (found (auth-source-recall spec))
+         filtered-backends accessor-key found-here goal)
+
+    (if (and found auth-source-do-cache)
+        (auth-source-do-debug
+         "auth-source-search: found %d CACHED results matching %S"
+         (length found) spec)
+
+      (assert
+       (or (eq t create) (listp create)) t
             "Invalid auth-source :create parameter (must be nil, t, or a list)")
 
     (setq filtered-backends (copy-list backends))
@@ -527,8 +530,14 @@ must call it to obtain the actual value."
 
       ;; change the :max parameter in the spec to the goal
       (setq spec (plist-put spec :max goal)))
+
+      (when (and found auth-source-do-cache)
+        (auth-source-remember spec found)))
+
     found))
 
+;;; (auth-source-search :max 1)
+;;; (funcall (plist-get (nth 0 (auth-source-search :max 1)) :secret))
 ;;; (auth-source-search :host "nonesuch" :type 'netrc :K 1)
 ;;; (auth-source-search :host "nonesuch" :type 'secrets)
 
@@ -553,6 +562,73 @@ Returns the deleted entries."
       (equal collection value)
       (member value collection)))
 
+(defun auth-source-forget-all-cached ()
+  "Forget all cached auth-source data."
+  (interactive)
+  (loop for sym being the symbols of password-data
+        ;; when the symbol name starts with auth-source-magic
+        when (string-match (concat "^" auth-source-magic)
+                           (symbol-name sym))
+        ;; remove that key
+        do (password-cache-remove (symbol-name sym))))
+
+(defun auth-source-remember (spec found)
+  "Remember FOUND search results for SPEC."
+  (password-cache-add
+   (concat auth-source-magic (format "%S" spec)) found))
+
+(defun auth-source-recall (spec)
+  "Recall FOUND search results for SPEC."
+  (password-read-from-cache
+   (concat auth-source-magic (format "%S" spec))))
+
+(defun auth-source-forget (spec)
+  "Forget any cached data matching SPEC exactly.
+
+This is the same SPEC you passed to `auth-source-search'.
+Returns t or nil for forgotten or not found."
+  (password-cache-remove (concat auth-source-magic (format "%S" spec))))
+
+;;; (loop for sym being the symbols of password-data when (string-match (concat "^" auth-source-magic) (symbol-name sym)) collect (symbol-name sym))
+
+;;; (auth-source-remember '(:host "wedd") '(4 5 6))
+;;; (auth-source-remember '(:host "xedd") '(1 2 3))
+;;; (auth-source-recall '(:host "xedd"))
+;;; (auth-source-recall '(:host t))
+;;; (auth-source-forget+ :host t)
+
+(defun* auth-source-forget+ (&rest spec &allow-other-keys)
+  "Forget any cached data matching SPEC.  Returns forgotten count.
+
+This is not a full `auth-source-search' spec but works similarly.
+For instance, \(:host \"myhost\" \"yourhost\") would find all the
+cached data that was found with a search for those two hosts,
+while \(:host t) would find all host entries."
+  (let ((count 0)
+        sname)
+    (loop for sym being the symbols of password-data
+          ;; when the symbol name matches with auth-source-magic
+          when (and (setq sname (symbol-name sym))
+                    (string-match (concat "^" auth-source-magic "\\(.+\\)")
+                                  sname)
+                    ;; and the spec matches what was stored in the cache
+                    (auth-source-specmatchp spec (read (match-string 1 sname))))
+          ;; remove that key
+          do (progn
+               (password-cache-remove sname)
+               (incf count)))
+    count))
+
+(defun auth-source-specmatchp (spec stored)
+  (let ((keys (loop for i below (length spec) by 2
+                   collect (nth i spec))))
+    (not (eq
+          (dolist (key keys)
+            (unless (auth-source-search-collection (plist-get stored key)
+                                                   (plist-get spec key))
+              (return 'no)))
+          'no))))
+
 ;;; Backend specific parsing: netrc/authinfo backend
 
 ;;; (auth-source-netrc-parse "~/.authinfo.gpg")
@@ -965,32 +1041,13 @@ login:
 
 ;;; older API
 
-(defun auth-source-forget-user-or-password
-  (mode host protocol &optional username)
-  "Remove cached authentication token."
-  (interactive "slogin/password: \nsHost: \nsProtocol: \n") ;for testing
-  (remhash
-   (if username
-       (format "%s %s:%s %s" mode host protocol username)
-     (format "%s %s:%s" mode host protocol))
-   auth-source-cache))
-
-(defun auth-source-forget-all-cached ()
-  "Forget all cached auth-source authentication tokens."
-  (interactive)
-  (setq auth-source-cache (make-hash-table :test 'equal)))
-
-;; (progn
-;;   (auth-source-forget-all-cached)
-;;   (list
-;;    (auth-source-user-or-password '("login" "password") "imap.myhost.com" "other")
-;;    (auth-source-user-or-password '("login" "password") "imap.myhost.com" "other" "tzz")
-;;    (auth-source-user-or-password '("login" "password") "imap.myhost.com" "other" "joe")))
-
 ;;; (auth-source-user-or-password '("login" "password") "imap.myhost.com" t "tzz")
 
-;; deprecate this interface
-(make-obsolete 'auth-source-user-or-password 'auth-source-search "Emacs 24.1")
+;; deprecate the old interface
+(make-obsolete 'auth-source-user-or-password
+               'auth-source-search "Emacs 24.1")
+(make-obsolete 'auth-source-forget-user-or-password
+               'auth-source-forget "Emacs 24.1")
 
 (defun auth-source-user-or-password
   (mode host protocol &optional username create-missing delete-existing)
@@ -1032,17 +1089,18 @@ MODE can be \"login\" or \"password\"."
          (search (if delete-existing
                      (append search (list :delete t))
                    search))
-         (found (if (not delete-existing)
-                    (gethash cname auth-source-cache)
-                  (remhash cname auth-source-cache)
-                  nil)))
+         ;; (found (if (not delete-existing)
+         ;;            (gethash cname auth-source-cache)
+         ;;          (remhash cname auth-source-cache)
+         ;;          nil)))
+         (found nil))
     (if found
         (progn
           (auth-source-do-debug
            "auth-source-user-or-password: DEPRECATED cached %s=%s for %s (%s) + %s"
            mode
            ;; don't show the password
-           (if (and (member "password" mode) auth-source-hide-passwords)
+           (if (and (member "password" mode) t)
                "SECRET"
              found)
            host protocol username)
diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index 41817c8..94c8f82 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -47,7 +47,7 @@
 (require 'nnmail)
 (require 'proto-stream)
 
-(autoload 'auth-source-forget-user-or-password "auth-source")
+(autoload 'auth-source-forget+ "auth-source")
 (autoload 'auth-source-search "auth-source")
 
 (nnoo-declare nnimap)
@@ -397,9 +397,7 @@ textual parts.")
 		  (dolist (host (list (nnoo-current-server 'nnimap)
 				      nnimap-address))
 		    (dolist (port ports)
-		      (dolist (element '("login" "password"))
-			(auth-source-forget-user-or-password
-			 element host port))))
+                      (auth-source-forget+ :host host :protocol port)))
 		  (delete-process (nnimap-process nnimap-object))
 		  (setq nnimap-object nil))))
 	    (when nnimap-object
diff --git a/lisp/password-cache.el b/lisp/password-cache.el
index fcae55a..8738aa6 100644
--- a/lisp/password-cache.el
+++ b/lisp/password-cache.el
@@ -111,9 +111,10 @@ that a password is invalid, so that `password-read' query the
 user again."
   (let ((password (symbol-value (intern-soft key password-data))))
     (when password
+      (when (stringp password)
       (if (fboundp 'clear-string)
 	  (clear-string password)
-	(fillarray password ?_))
+          (fillarray password ?_)))
       (unintern key password-data))))
 
 (defun password-cache-add (key password)

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog         |   35 ++++++++
 lisp/auth-source.el    |  228 ++++++++++++++++++++++++++++++------------------
 lisp/message.el        |    2 +-
 lisp/nnimap.el         |    6 +-
 lisp/nntp.el           |    4 +-
 lisp/password-cache.el |    7 +-
 lisp/shr.el            |    3 +-
 7 files changed, 189 insertions(+), 96 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, tzz-auth-source-rewrite has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.