changeset 94837:55eb2a3c59b4

Merge from gnus--devo--0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1153
author Miles Bader <miles@gnu.org>
date Sat, 10 May 2008 05:34:55 +0000
parents 3cb546529dde
children 2a1620ce5398
files lisp/gnus/ChangeLog lisp/gnus/auth-source.el lisp/gnus/nnimap.el lisp/gnus/nntp.el
diffstat 4 files changed, 66 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Sat May 10 04:39:08 2008 +0000
+++ b/lisp/gnus/ChangeLog	Sat May 10 05:34:55 2008 +0000
@@ -1,3 +1,15 @@
+2008-05-09  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* nntp.el: Autoload `auth-source-user-or-password'.
+	(nntp-send-authinfo): Use it.
+
+	* nnimap.el: Autoload `auth-source-user-or-password'.
+	(nnimap-open-connection): Use it.
+
+	* auth-source.el: Added docs on using with url-auth.  Import gnus-util
+	for the gnus-message function.
+	(auth-source-user-or-password): Use it.
+
 2008-05-08  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* rfc2104.el (rfc2104-hexstring-to-bitstring): Rename it back from
--- a/lisp/gnus/auth-source.el	Sat May 10 04:39:08 2008 +0000
+++ b/lisp/gnus/auth-source.el	Sat May 10 05:34:55 2008 +0000
@@ -39,8 +39,18 @@
 
 ;; before you put some data in ~/.authinfo.gpg (the default place)
 
+;;; For url-auth authentication (HTTP/HTTPS), you need to use:
+
+;;; machine yourmachine.com:80 port http login testuser password testpass
+
+;;; This will match any realm and authentication method (basic or
+;;; digest).  If you want finer controls, explore the url-auth source
+;;; code and variables.
+
 ;;; Code:
 
+(require 'gnus-util)
+
 (eval-when-compile (require 'cl))
 (eval-when-compile (require 'netrc))
 
@@ -135,6 +145,9 @@
 
 (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 
@@ -144,6 +157,12 @@
 		   (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)
 	(return found)))))
 
 (defun auth-source-protocol-defaults (protocol)
--- a/lisp/gnus/nnimap.el	Sat May 10 04:39:08 2008 +0000
+++ b/lisp/gnus/nnimap.el	Sat May 10 05:34:55 2008 +0000
@@ -71,6 +71,9 @@
 
 (eval-when-compile (require 'cl))
 
+(eval-and-compile
+  (autoload 'auth-source-user-or-password "auth-source"))
+
 (nnoo-declare nnimap)
 
 (defconst nnimap-version "nnimap 1.0")
@@ -796,22 +799,26 @@
  	   (port (if nnimap-server-port
  		     (int-to-string nnimap-server-port)
  		   "imap"))
-	   (user (netrc-machine-user-or-password
-		  "login"
-		  list
-		  (list server
-			(or nnimap-server-address
-			    nnimap-address))
-		  (list port)
-		  (list "imap" "imaps" "143" "993")))
-	   (passwd (netrc-machine-user-or-password
-		    "password"
-		    list
-		    (list server
-			  (or nnimap-server-address
-			      nnimap-address))
-		    (list port)
-		    (list "imap" "imaps" "143" "993"))))
+	   (user (or 
+		  (auth-source-user-or-password "login" server port) ; this is preferred to netrc-*
+		  (netrc-machine-user-or-password
+		   "login"
+		   list
+		   (list server
+			 (or nnimap-server-address
+			     nnimap-address))
+		   (list port)
+		   (list "imap" "imaps" "143" "993"))))
+	   (passwd (or 
+		    (auth-source-user-or-password "login" server port) ; this is preferred to netrc-*
+		    (netrc-machine-user-or-password
+		     "password"
+		     list
+		     (list server
+			   (or nnimap-server-address
+			       nnimap-address))
+		     (list port)
+		     (list "imap" "imaps" "143" "993")))))
       (if (imap-authenticate user passwd nnimap-server-buffer)
 	  (prog2
 	      (setq nnimap-server-buffer-alist
--- a/lisp/gnus/nntp.el	Sat May 10 04:39:08 2008 +0000
+++ b/lisp/gnus/nntp.el	Sat May 10 05:34:55 2008 +0000
@@ -36,6 +36,9 @@
 
 (eval-when-compile (require 'cl))
 
+(eval-and-compile
+  (autoload 'auth-source-user-or-password "auth-source"))
+
 (defgroup nntp nil
   "NNTP access for Gnus."
   :group 'gnus)
@@ -1177,8 +1180,15 @@
   (let* ((list (netrc-parse nntp-authinfo-file))
 	 (alist (netrc-machine list nntp-address "nntp"))
 	 (force (or (netrc-get alist "force") nntp-authinfo-force))
-	 (user (or (netrc-get alist "login") nntp-authinfo-user))
-	 (passwd (netrc-get alist "password")))
+	 (user (or 
+		;; this is preferred to netrc-*
+		(auth-source-user-or-password "login" nntp-address "nntp")
+		(netrc-get alist "login") 
+		nntp-authinfo-user))
+	 (passwd (or
+		  ;; this is preferred to netrc-*
+		  (auth-source-user-or-password "password" nntp-address "nntp")
+		  (netrc-get alist "password"))))
     (when (or (not send-if-force)
 	      force)
       (unless user