Gnus development mailing list
 help / color / mirror / Atom feed
* Re: pgg-gpg stalls
       [not found]   ` <87odze8tth.fsf@pacem.orebokech.com>
@ 2006-04-06 18:47     ` Reiner Steib
  2006-04-06 19:10       ` Romain Francoise
  0 siblings, 1 reply; 7+ messages in thread
From: Reiner Steib @ 2006-04-06 18:47 UTC (permalink / raw)
  Cc: Thomas Baumann, emacs-pretest-bug, Daiki Ueno, ding

On Thu, Apr 06 2006, Romain Francoise wrote:

> Thomas Baumann <thomas.baumann@ch.tum.de> writes:
>
>> sending of signed emails is currently impossible.
>
>> after sending an email in MH-E, emacs waits (endlessly) for something
>> until C-g is pressed leaving the process pgg-gpg running.
>
>> This worked before with pgg-gpg of 2006-02-10.
>
> Please update and try again, we (the Gnus developers) have decided to
> revert the last batch of new features that went in PGG, in order to
> stabilize the upcoming Gnus 5.10.8 release.

I wasn't not sure if `allout.el' depends on the symmetric encryption
features, so I didn't revert it in Emacs CVS.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pgg-gpg stalls
  2006-04-06 18:47     ` pgg-gpg stalls Reiner Steib
@ 2006-04-06 19:10       ` Romain Francoise
  2006-04-06 22:50         ` Ken Manheimer
  2006-04-07 12:46         ` pgg-gpg stalls Thomas Baumann
  0 siblings, 2 replies; 7+ messages in thread
From: Romain Francoise @ 2006-04-06 19:10 UTC (permalink / raw)
  Cc: Thomas Baumann, emacs-pretest-bug, Ken Manheimer, Daiki Ueno, ding

Reiner Steib <reinersteib+gmane@imap.cc> writes:

> I wasn't not sure if `allout.el' depends on the symmetric encryption
> features, so I didn't revert it in Emacs CVS.

Actually it's the other way around, the recent changes to PGG broke
allout's encryption code, so reverting them makes allout work again.

See:

| From: "Ken Manheimer" <ken.manheimer@gmail.com>
| Subject: Re: Small patch to enable use of gpg-agent with pgg
| Message-ID: <2cd46e7f0604011630r6388edackc4c7ef21b92ecaa7@mail.gmail.com>
| Date: Sat, 1 Apr 2006 19:30:04 -0500

-- 
Romain Francoise <romain@orebokech.com> | The sea! the sea! the open
it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
                                        | ever free! --Bryan W. Procter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pgg-gpg stalls
  2006-04-06 19:10       ` Romain Francoise
@ 2006-04-06 22:50         ` Ken Manheimer
  2006-04-07  3:46           ` Bad usage of pgg-gpg-* functions in allout.el Daiki Ueno
  2006-04-07 12:46         ` pgg-gpg stalls Thomas Baumann
  1 sibling, 1 reply; 7+ messages in thread
From: Ken Manheimer @ 2006-04-06 22:50 UTC (permalink / raw)
  Cc: Thomas Baumann, emacs-pretest-bug, Daiki Ueno, ding, Reiner Steib

thank you!  allout's encryption seems to be working with your reversion.

to be exact, allout does depend on the symmetric encryption features
(as well as some other moderately recent additions), but they were
included a while back, and are all part of the version to which you
reverted.

On 4/6/06, Romain Francoise <romain@orebokech.com> wrote:
> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>
> > I wasn't not sure if `allout.el' depends on the symmetric encryption
> > features, so I didn't revert it in Emacs CVS.
>
> Actually it's the other way around, the recent changes to PGG broke
> allout's encryption code, so reverting them makes allout work again.
>
> See:
>
> | From: "Ken Manheimer" <ken.manheimer@gmail.com>
> | Subject: Re: Small patch to enable use of gpg-agent with pgg
> | Message-ID: <2cd46e7f0604011630r6388edackc4c7ef21b92ecaa7@mail.gmail.com>
> | Date: Sat, 1 Apr 2006 19:30:04 -0500
>
> --
> Romain Francoise <romain@orebokech.com> | The sea! the sea! the open
> it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
>                                         | ever free! --Bryan W. Procter
>


--
ken manheimer
ken.manheimer@gmail.com
http://myriadicity.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Bad usage of pgg-gpg-* functions in allout.el
  2006-04-06 22:50         ` Ken Manheimer
@ 2006-04-07  3:46           ` Daiki Ueno
  2006-04-07  9:43             ` Daiki Ueno
  0 siblings, 1 reply; 7+ messages in thread
From: Daiki Ueno @ 2006-04-07  3:46 UTC (permalink / raw)
  Cc: ding, emacs-devel

>>>>> In <2cd46e7f0604061550j44c97f68v4c6cffda79a4e0ce@mail.gmail.com> 
>>>>>	"Ken Manheimer" <ken.manheimer@gmail.com> wrote:
> thank you!  allout's encryption seems to be working with your reversion.

Aside from the reversion of pgg-gpg.el, when I looked into allout.el's
encryption stuff, I found that 4 undocumented non-interface functions
of pgg-gpg are used:

pgg-gpg-lookup-key-owner
pgg-gpg-symmetric-key-p
pgg-gpg-select-matching-key
pgg-gpg-key-id-from-key-owner 

Fortunately, the latter 3 functions do _not_ call "gpg".  Ken, would you
please copy these functions from pgg-gpg.el into allout.el and replace
s/pgg-gpg/allout/?  Otherwise, these functions may be abolished again in
the future version of PGG.

pgg-gpg-lookup-key-owner needs to be implemented as an interface
function.  I'm now working on this.

Regards,
-- 
Daiki Ueno

^ permalink raw reply	[flat|nested] 7+ messages in thread

* PGG updates
@ 2006-04-07  8:09 Daiki Ueno
       [not found] ` <27877.1144257571@norvel.baumann-gauting.site>
  0 siblings, 1 reply; 7+ messages in thread
From: Daiki Ueno @ 2006-04-07  8:09 UTC (permalink / raw)
  Cc: ding

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

Patch from Gnus' trunk is attached.  Major changes are listed below.

* Changed pgg-gpg-decrypt-region to write out an encrypted armor to a
file.  This should fix the problem Sacsha reported.

* Added new interface function pgg-list-keys.  This function returns
more information about keys than pgg-lookup-key.  For example:

  (pgg-list-keys "ueno")
  =>
  (((pub (trust . "u") (length . 1024) (algorithm . 17)
         (key-id . "A5B6B2D4B15813FE") (creation-date . "1002618643")
         (expiration-date . "1155189267") (ownertrust . "u")
         (capability . "scESC"))
    (uid (trust . "u") (creation-date . "1060581267")
         (hash . "461300972A811B7CDF6EE9ED3E918AD940E4F384")
         (user-id . "Daiki Ueno <ueno@unixuser.org>"))))

* Added some notes in comments/docstrings of backend functions to
prevent direct usage.

* pgg-gpg-recipient-argument is abolished, because "-r" has the same
meaning as "--remote-user" and "--recipient".


[-- Attachment #2: pgg-gpg.el.diff --]
[-- Type: application/octet-stream, Size: 29774 bytes --]

Index: lisp/pgg-gpg.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/pgg-gpg.el,v
retrieving revision 7.22
diff -u -r7.22 pgg-gpg.el
--- lisp/pgg-gpg.el	5 Apr 2006 12:57:22 -0000	7.22
+++ lisp/pgg-gpg.el	7 Apr 2006 08:07:26 -0000
@@ -25,6 +25,11 @@
 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 ;; Boston, MA 02110-1301, USA.
 
+;;; Commentary:
+
+;; NOTE: This file is a backend of pgg.el.  Please do not directly
+;; call functions defined in this file from your program.
+
 ;;; Code:
 
 (eval-when-compile
@@ -44,12 +49,6 @@
   :group 'pgg-gpg
   :type '(repeat (string :tag "Argument")))
 
-(defcustom pgg-gpg-recipient-argument "--recipient"
-  "GnuPG option to specify recipient."
-  :group 'pgg-gpg
-  :type '(choice (const :tag "New `--recipient' option" "--recipient")
-		 (const :tag "Old `--remote-user' option" "--remote-user")))
-
 (defcustom pgg-gpg-use-agent nil
   "Whether to use gnupg agent for key caching."
   :group 'pgg-gpg
@@ -62,20 +61,56 @@
   "An alist mapping from key ID to user ID.")
 
 (defvar pgg-gpg-read-point nil)
-(defvar pgg-gpg-output-file-name nil)
 (defvar pgg-gpg-pending-status-list nil)
 (defvar pgg-gpg-key-id nil)
 (defvar pgg-gpg-passphrase nil)
 (defvar pgg-gpg-debug nil)
 
+(defvar pgg-gpg-colons-pub-spec
+  '((trust "[^:]")
+    (length "[0-9]+" 0 string-to-number)
+    (algorithm "[0-9]+" 0 string-to-number)
+    (key-id "[^:]+")
+    (creation-date "[0-9]+")
+    (expiration-date "[0-9]+")
+    nil
+    (ownertrust "[^:]")
+    nil
+    nil
+    (capability "[escaESCA]*")))
+
+(defvar pgg-gpg-colons-sec-spec
+  '((trust "[^:]")
+    (length "[0-9]+" 0 string-to-number)
+    (algorithm "[0-9]+" 0 string-to-number)
+    (key-id "[^:]+")
+    (creation-date "[0-9]+")
+    (expiration-date "[0-9]+")
+    nil
+    (ownertrust "[^:]")))
+
+(defvar pgg-gpg-colons-uid-spec
+  '((trust "[^:]")
+    nil
+    nil
+    nil
+    (creation-date "[0-9]+")
+    (expiration-date "[0-9]+")
+    (hash "[^:]+")
+    nil
+    (user-id "[^:]+")))
+    
 (defun pgg-gpg-start-process (args)
-  (let* ((output-file-name (pgg-make-temp-file "pgg-output"))
-	 (args
+  "This function is for internal use only.
+
+Start pgg-gpg-program in a subprocess with given ARGS.
+Return the process object for it."
+  (let* ((args
 	  (append (list "--no-tty"
 			"--status-fd" "1"
 			"--command-fd" "0"
 			"--yes" ; overwrite
-			"--output" output-file-name)
+			)
 		  (if pgg-gpg-use-agent '("--use-agent"))
 		  pgg-gpg-extra-args
 		  args))
@@ -87,8 +122,6 @@
     (with-current-buffer buffer
       (make-local-variable 'pgg-gpg-read-point)
       (setq pgg-gpg-read-point (point-min))
-      (make-local-variable 'pgg-gpg-output-file-name)
-      (setq pgg-gpg-output-file-name output-file-name)
       (make-local-variable 'pgg-gpg-pending-status-list)
       (setq pgg-gpg-pending-status-list nil)
       (make-local-variable 'pgg-gpg-key-id)
@@ -145,22 +178,17 @@
 	(set-buffer (get-buffer-create pgg-errors-buffer))
 	(buffer-disable-undo)
 	(erase-buffer)
-	(insert-buffer-substring (process-buffer process))
-	;; Read the contents of the output file to pgg-output-buffer.
-	(set-buffer (get-buffer-create pgg-output-buffer))
-	(buffer-disable-undo)
-	(erase-buffer)
-	(if (equal status "finished\n")
-	    (let ((output-file-name
-		   (with-current-buffer (process-buffer process)
-		     pgg-gpg-output-file-name)))
-	      (when (file-exists-p output-file-name)
-		(let ((coding-system-for-read (if pgg-text-mode
-						  'raw-text
-						'binary)))
-		  (insert-file-contents output-file-name))
-		(delete-file output-file-name))))
-	(kill-buffer (process-buffer process)))))
+	(insert-buffer-substring (process-buffer process)))))
+
+(defun pgg-gpg-read-output-file (output-file-name)
+  (set-buffer (get-buffer-create pgg-output-buffer))
+  (buffer-disable-undo)
+  (erase-buffer)
+  (if (file-exists-p output-file-name)
+      (let ((coding-system-for-read (if pgg-text-mode
+					'raw-text
+				      'binary)))
+	(insert-file-contents output-file-name))))
 
 (defun pgg-gpg-wait-for-status (process status-list)
   (with-current-buffer (process-buffer process)
@@ -224,7 +252,9 @@
     (setq pgg-gpg-passphrase nil)))
 
 (defun pgg-gpg-lookup-key (string &optional type)
-  "Search keys associated with STRING."
+  "This function is for internal use only.
+
+Search keys associated with STRING."
   (let ((args (list "--with-colons" "--no-greeting" "--batch"
 		    (if type "--list-secret-keys" "--list-keys")
 		    string)))
@@ -235,117 +265,304 @@
 			     nil t)
 	  (substring (match-string 2) 8)))))
 
+(defun pgg-gpg-list-keys (name &optional secret)
+  "This function is for internal use only.
+
+Search keys associated with STRING."
+  (let ((args (list "--with-colons" "--no-greeting" "--batch"
+		    "--fixed-list-mode"
+		    (if secret "--list-secret-keys" "--list-keys")
+		    name))
+	keys
+	type
+	symbol
+	pointer)
+    (with-temp-buffer
+      (apply #'call-process pgg-gpg-program nil (list t nil) nil args)
+      (goto-char (point-min))
+      (while (looking-at "\\([a-z][a-z][a-z]\\):\\(.*\\)")
+	(setq type (match-string 1)
+	      symbol (intern-soft (format "pgg-gpg-colons-%s-spec" type)))
+	(if (member type '("pub" "sec"))
+	    (setq keys (cons nil keys)))
+	(if (and symbol
+		 (boundp symbol))
+	    (setcar keys (cons (cons (intern type)
+				     (pgg-gpg-parse-colons
+				      (symbol-value symbol)
+				      (match-string 2)))
+			       (car keys))))
+	(forward-line)))
+    (setq pointer keys)
+    (while pointer
+      (setcar pointer (nreverse (car pointer)))
+      (setq pointer (cdr pointer)))
+    (nreverse keys)))
+
+(defun pgg-gpg-parse-colons (alist string)
+  (let ((index 0)
+	result)
+    (while (and alist
+		(or (null (car alist))
+		    (eq index
+			(string-match
+			 (concat "\\(" (nth 1 (car alist)) "\\)?:")
+			 string index))))
+      (if (car alist)
+	  (progn
+	    (setq index (match-end 0))
+	    (if (match-beginning 1)
+		(setq result (cons (cons (car (car alist))
+					 (funcall
+					  (or (nth 3 (car alist)) #'identity)
+					  (match-string
+					   (1+ (or (nth 2 (car alist)) 0))
+					   string)))
+				   result))))
+	(setq index (1+ index)))
+      (setq alist (cdr alist)))
+    (nreverse result)))
+
 (defun pgg-gpg-encrypt-region (start end recipients &optional sign passphrase)
-  "Encrypt the current region between START and END.
+  "This function is for internal use only.
+
+Encrypt the current region between START and END.
 
-If optional argument SIGN is non-nil, do a combined sign and encrypt."
+If optional argument SIGN is non-nil, do a combined sign and encrypt.
+
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
+	 (output-file-name (pgg-make-temp-file "pgg-output"))
 	 (args
 	  (append
-	   '("--armor" "--always-trust" "--encrypt")
+	   (list "--armor" "--always-trust" "--encrypt"
+		 "--output" output-file-name)
+	   (if passphrase '("--passphrase-fd" "0"))
 	   (if pgg-text-mode '("--textmode"))
 	   (if sign (list "--sign" "--local-user" pgg-gpg-user-id))
 	   (if recipients
 	       (apply #'nconc
 		      (mapcar (lambda (rcpt)
-				(list pgg-gpg-recipient-argument rcpt))
-			      (append recipients
-				      (if pgg-encrypt-for-me
-					  (list pgg-gpg-user-id))))))))
-	 (process (pgg-gpg-start-process args)))
-    (if (and sign (not pgg-gpg-use-agent))
-	(pgg-gpg-wait-for-status process '("BEGIN_SIGNING" "GOOD_PASSPHRASE")))
-    (process-send-region process start end)
-    (pgg-gpg-wait-for-completion process)
-    (save-excursion
-      (set-buffer (get-buffer-create pgg-errors-buffer))
-      (goto-char (point-max))
-      (not (null (re-search-backward "^\\[GNUPG:] END_ENCRYPTION\\>"
-				     nil t))))))
+				(list "-r" rcpt))
+			      (if pgg-encrypt-for-me
+				  (cons pgg-gpg-user-id recipients)
+				recipients))))))
+	 process status)
+    (unwind-protect
+	(progn
+	  (setq process (pgg-gpg-start-process args))
+	  (if (and passphrase
+		   (eq (process-status process) 'run))
+	      (process-send-string process (concat passphrase "\n")))
+	  (if (and sign (not pgg-gpg-use-agent))
+	      (pgg-gpg-wait-for-status process
+				       '("BEGIN_SIGNING" "GOOD_PASSPHRASE")))
+	  (if (eq (process-status process) 'run)
+	      (process-send-region process start end))
+	  (pgg-gpg-wait-for-completion process)
+	  (save-excursion
+	    (set-buffer (get-buffer pgg-errors-buffer))
+	    (goto-char (point-max))
+	    (setq status (not (null (re-search-backward
+				     "^\\[GNUPG:] END_ENCRYPTION\\>"
+				     nil t)))))
+	  (if status
+	      (pgg-gpg-read-output-file output-file-name))
+	  status)
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process)))
+      (if (file-exists-p output-file-name)
+	  (delete-file output-file-name)))))
 
 (defun pgg-gpg-encrypt-symmetric-region (start end &optional passphrase)
-  "Encrypt the current region between START and END with symmetric cipher."
-  (let* ((args
-	  (append '("--armor" "--symmetric")
+  "This function is for internal use only.
+
+Encrypt the current region between START and END with symmetric cipher.
+
+If optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
+  (let* ((output-file-name (pgg-make-temp-file "pgg-output"))
+	 (args
+	  (append (list "--armor" "--symmetric"
+			"--output" output-file-name)
+		  (if passphrase '("--passphrase-fd" "0"))
 		  (if pgg-text-mode '("--textmode"))))
-	 (process (pgg-gpg-start-process args)))
-    (pgg-gpg-wait-for-status process '("BEGIN_ENCRYPTION"))
-    (process-send-region process start end)
-    (pgg-gpg-wait-for-completion process)
-    (save-excursion
-      (set-buffer (get-buffer-create pgg-errors-buffer))
-      (goto-char (point-max))
-      (not (null (re-search-backward "^\\[GNUPG:] END_ENCRYPTION\\>"
-				     nil t))))))
+	 process status)
+    (unwind-protect
+	(progn
+	  (setq process (pgg-gpg-start-process args))
+	  (if (and passphrase
+		   (eq (process-status process) 'run))
+	      (process-send-string process (concat passphrase "\n")))
+	  (pgg-gpg-wait-for-status process '("BEGIN_ENCRYPTION"))
+	  (if (eq (process-status process) 'run)
+	      (process-send-region process start end))
+	  (pgg-gpg-wait-for-completion process)
+	  (save-excursion
+	    (set-buffer (get-buffer pgg-errors-buffer))
+	    (goto-char (point-max))
+	    (setq status (not (null (re-search-backward
+				     "^\\[GNUPG:] END_ENCRYPTION\\>"
+				     nil t)))))
+	  (if status
+	      (pgg-gpg-read-output-file output-file-name))
+	  status)
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process)))
+      (if (file-exists-p output-file-name)
+	  (delete-file output-file-name)))))
 
 (defun pgg-gpg-decrypt-region (start end &optional passphrase)
-  "Decrypt the current region between START and END."
-  (let* ((args '("--decrypt"))
-	 (process (pgg-gpg-start-process args)))
-    (process-send-region process start end)
-    (pgg-gpg-wait-for-status process '("BEGIN_DECRYPTION"))
-    (pgg-gpg-wait-for-completion process)
-    (save-excursion
-      (set-buffer (get-buffer-create pgg-errors-buffer))
-      (goto-char (point-max))
-      (not (null (re-search-backward "^\\[GNUPG:] DECRYPTION_OKAY\\>"
-				     nil t))))))
+  "This function is for internal use only.
+
+Decrypt the current region between START and END.
+
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
+  (let* ((input-file-name (pgg-make-temp-file "pgg-input"))
+	 (output-file-name (pgg-make-temp-file "pgg-output"))
+	 (args (append
+		(list "--decrypt" "--output" output-file-name input-file-name)
+		(if passphrase '("--passphrase-fd" "0"))))
+	 process status)
+    (unwind-protect
+	(progn
+	  (write-region start end input-file-name)
+	  (setq process (pgg-gpg-start-process args))
+	  (if (and passphrase
+		   (eq (process-status process) 'run))
+	      (process-send-string process (concat passphrase "\n")))
+	  (pgg-gpg-wait-for-status process '("BEGIN_DECRYPTION"))
+	  (pgg-gpg-wait-for-completion process)
+	  (save-excursion
+	    (set-buffer (get-buffer-create pgg-errors-buffer))
+	    (goto-char (point-max))
+	    (setq status (not (null (re-search-backward
+				     "^\\[GNUPG:] DECRYPTION_OKAY\\>"
+				     nil t)))))
+	  (if status
+	      (pgg-gpg-read-output-file output-file-name))
+	  status)
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process)))
+      (if (file-exists-p input-file-name)
+	  (delete-file input-file-name))
+      (if (file-exists-p output-file-name)
+	  (delete-file output-file-name)))))
 
 (defun pgg-gpg-sign-region (start end &optional cleartext passphrase)
-  "Make detached signature from text between START and END."
-  (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
+  "This function is for internal use only.
+
+Make detached signature from text between START and END.
+
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
+  (let* ((output-file-name (pgg-make-temp-file "pgg-output"))
+	 (pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
 	 (args
 	  (append (list (if cleartext "--clearsign" "--detach-sign")
 			"--armor" "--verbose"
-			"--local-user" pgg-gpg-user-id)
+			"--local-user" pgg-gpg-user-id
+			"--output" output-file-name)
+		  (if passphrase '("--passphrase-fd" "0"))
 		  (if pgg-text-mode '("--textmode"))))
-	 (process (pgg-gpg-start-process args)))
-    (unless pgg-gpg-use-agent
-      (pgg-gpg-wait-for-status process '("BEGIN_SIGNING" "GOOD_PASSPHRASE")))
-    (process-send-region process start end)
-    (pgg-gpg-wait-for-completion process)
-    (save-excursion
-      (set-buffer (get-buffer-create pgg-errors-buffer))
-      (goto-char (point-max))
-      (not (null (re-search-backward "^\\[GNUPG:] SIG_CREATED\\>"
-				     nil t))))))
+	 process status)
+    (unwind-protect
+	(progn
+	  (setq process (pgg-gpg-start-process args))
+	  (if (and passphrase
+		   (eq (process-status process) 'run))
+	      (process-send-string process (concat passphrase "\n")))
+	  (unless pgg-gpg-use-agent
+	    (pgg-gpg-wait-for-status process
+				     '("BEGIN_SIGNING" "GOOD_PASSPHRASE")))
+	  (if (eq (process-status process) 'run)
+	      (process-send-region process start end))
+	  (pgg-gpg-wait-for-completion process)
+	  (save-excursion
+	    (set-buffer (get-buffer-create pgg-errors-buffer))
+	    (goto-char (point-max))
+	    (setq status (not (null (re-search-backward
+				     "^\\[GNUPG:] SIG_CREATED\\>"
+				     nil t)))))
+	  (if status
+	      (pgg-gpg-read-output-file output-file-name))
+	  status)
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process)))
+      (if (file-exists-p output-file-name)
+	  (delete-file output-file-name)))))
 
 (defun pgg-gpg-verify-region (start end &optional signature)
-  "Verify region between START and END as the detached signature SIGNATURE."
-  (let ((args '("--verify"))
-	process)
-    (when (stringp signature)
-      (setq args (append args (list signature))))
-    (setq process (pgg-gpg-start-process (append args '("-"))))
-    (process-send-region process start end)
-    (pgg-gpg-wait-for-completion process)
-    (save-excursion
-      (set-buffer (get-buffer-create pgg-errors-buffer))
-      (goto-char (point-max))
-      (not (null (re-search-backward "^\\[GNUPG:] GOODSIG\\>"
-				     nil t))))))
+  "This function is for internal use only.
+
+Verify region between START and END as the detached signature SIGNATURE."
+  (let* ((output-file-name (pgg-make-temp-file "pgg-output"))
+	 (args (list "--verify" "--output" output-file-name))
+	 process status)
+    (if signature
+	(setq args (append args (list signature))))
+    (unwind-protect
+	(progn
+	  (setq process (pgg-gpg-start-process (append args '("-"))))
+	  (if (eq (process-status process) 'run)
+	      (process-send-region process start end))
+	  (pgg-gpg-wait-for-completion process)
+	  (save-excursion
+	    (set-buffer (get-buffer-create pgg-errors-buffer))
+	    (goto-char (point-max))
+	    (setq status (not (null (re-search-backward
+				     "^\\[GNUPG:] GOODSIG\\>"
+				     nil t)))))
+	  (if status
+	      (pgg-gpg-read-output-file output-file-name))
+	  status)
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process)))
+      (if (file-exists-p output-file-name)
+	  (delete-file output-file-name)))))
 
 (defun pgg-gpg-insert-key ()
-  "Insert public key at point."
+  "This function is for internal use only.
+
+Insert public key at point."
   (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
-	 (args (list "--export" "--armor"
+	 (output-file-name (pgg-make-temp-file "pgg-output"))
+	 (args (list "--export" "--armor" "--output" output-file-name
 		     pgg-gpg-user-id))
-	 (process (pgg-gpg-start-process args)))
-    (pgg-gpg-wait-for-completion process)
-    (insert-buffer-substring pgg-output-buffer)))
+	 process status)
+    (unwind-protect
+	(progn
+	  (setq process (pgg-gpg-start-process args))
+	  (pgg-gpg-wait-for-completion process)
+	  (pgg-gpg-read-output-file output-file-name)
+	  (insert-buffer-substring pgg-output-buffer))
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process)))
+      (if (file-exists-p output-file-name)
+	  (delete-file output-file-name)))))
 
 (defun pgg-gpg-snarf-keys-region (start end)
-  "Add all public keys in region between START and END to the keyring."
-  (let* ((args '("--import" "-"))
-	 (process (pgg-gpg-start-process args))
-	 status)
-    (process-send-region process start end)
-    (pgg-gpg-wait-for-completion process)
-    (save-excursion
-      (set-buffer (get-buffer-create pgg-errors-buffer))
-      (goto-char (point-max))
-      (not (null (re-search-backward "^\\[GNUPG:] IMPORT_RES\\>"
-				     nil t))))))
+  "This function is for internal use only.
+
+Add all public keys in region between START and END to the keyring."
+  (let ((args '("--import" "-"))
+	process)
+    (unwind-protect
+	(progn
+	  (setq process (pgg-gpg-start-process args))
+	  (if (eq (process-status process) 'run)
+	      (process-send-region process start end))
+	  (pgg-gpg-wait-for-completion process)
+	  (save-excursion
+	    (set-buffer (get-buffer-create pgg-errors-buffer))
+	    (goto-char (point-max))
+	    (not (null (re-search-backward
+			"^\\[GNUPG:] IMPORT_RES\\>"
+			nil t)))))
+      (if (and process (buffer-live-p (process-buffer process)))
+	  (kill-buffer (process-buffer process))))))
 
 (provide 'pgg-gpg)
 
Index: lisp/pgg-pgp.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/pgg-pgp.el,v
retrieving revision 7.10
diff -u -r7.10 pgg-pgp.el
--- lisp/pgg-pgp.el	8 Feb 2006 04:17:15 -0000	7.10
+++ lisp/pgg-pgp.el	7 Apr 2006 08:07:27 -0000
@@ -24,6 +24,11 @@
 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 ;; Boston, MA 02110-1301, USA.
 
+;;; Commentary:
+
+;; NOTE: This file is a backend of pgg.el.  Please do not directly
+;; call functions defined in this file from your program.
+
 ;;; Code:
 
 (eval-when-compile
@@ -115,7 +120,9 @@
 	(file-error nil)))))
 
 (defun pgg-pgp-lookup-key (string &optional type)
-  "Search keys associated with STRING."
+  "This function is for internal use only.
+
+Search keys associated with STRING."
   (let ((args (list "+batchmode" "+language=en" "-kv" string)))
     (with-current-buffer (get-buffer-create pgg-output-buffer)
       (buffer-disable-undo)
@@ -133,7 +140,9 @@
 	 2))))))
 
 (defun pgg-pgp-encrypt-region (start end recipients &optional sign passphrase)
-  "Encrypt the current region between START and END."
+  "This function is for internal use only.
+
+Encrypt the current region between START and END."
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
 	 (passphrase (or passphrase
 			 (when sign
@@ -155,7 +164,9 @@
     (pgg-process-when-success nil)))
 
 (defun pgg-pgp-decrypt-region (start end &optional passphrase)
-  "Decrypt the current region between START and END.
+  "This function is for internal use only.
+
+Decrypt the current region between START and END.
 
 If optional PASSPHRASE is not specified, it will be obtained from the
 passphrase cache or user."
@@ -173,7 +184,9 @@
 	  (pgg-add-passphrase-to-cache key passphrase)))))
 
 (defun pgg-pgp-sign-region (start end &optional clearsign passphrase)
-  "Make detached signature from text between START and END.
+  "This function is for internal use only.
+
+Make detached signature from text between START and END.
 
 If optional PASSPHRASE is not specified, it will be obtained from the
 passphrase cache or user."
@@ -202,7 +215,9 @@
 	       passphrase)))))))
 
 (defun pgg-pgp-verify-region (start end &optional signature)
-  "Verify region between START and END as the detached signature SIGNATURE."
+  "This function is for internal use only.
+
+Verify region between START and END as the detached signature SIGNATURE."
   (let* ((orig-file (pgg-make-temp-file "pgg"))
 	 (args '("+verbose=1" "+batchmode" "+language=us"))
 	 (orig-mode (default-file-modes)))
@@ -234,7 +249,9 @@
 			      (point)))))))
 
 (defun pgg-pgp-insert-key ()
-  "Insert public key at point."
+  "This function is for internal use only.
+
+Insert public key at point."
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
 	 (args
 	  (list "+verbose=1" "+batchmode" "+language=us" "-kxaf"
@@ -243,7 +260,9 @@
     (insert-buffer-substring pgg-output-buffer)))
 
 (defun pgg-pgp-snarf-keys-region (start end)
-  "Add all public keys in region between START and END to the keyring."
+  "This function is for internal use only.
+
+Add all public keys in region between START and END to the keyring."
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
 	 (key-file (pgg-make-temp-file "pgg"))
 	 (args
Index: lisp/pgg-pgp5.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/pgg-pgp5.el,v
retrieving revision 7.7
diff -u -r7.7 pgg-pgp5.el
--- lisp/pgg-pgp5.el	19 Jan 2006 11:53:12 -0000	7.7
+++ lisp/pgg-pgp5.el	7 Apr 2006 08:07:27 -0000
@@ -24,6 +24,11 @@
 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 ;; Boston, MA 02110-1301, USA.
 
+;;; Commentary:
+
+;; NOTE: This file is a backend of pgg.el.  Do not directly call
+;; functions defined in this file from your program.
+
 ;;; Code:
 
 (eval-when-compile
@@ -130,7 +135,9 @@
 	(file-error nil)))))
 
 (defun pgg-pgp5-lookup-key (string &optional type)
-  "Search keys associated with STRING."
+  "This function is for internal use only.
+
+Search keys associated with STRING."
   (let ((args (list "+language=en" "-l" string)))
     (with-current-buffer (get-buffer-create pgg-output-buffer)
       (buffer-disable-undo)
@@ -144,7 +151,9 @@
 	 2)))))
 
 (defun pgg-pgp5-encrypt-region (start end recipients &optional sign passphrase)
-  "Encrypt the current region between START and END."
+  "This function is for internal use only.
+
+Encrypt the current region between START and END."
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
 	 (passphrase (or passphrase
 			 (when sign
@@ -181,7 +190,9 @@
     (pgg-process-when-success nil)))
 
 (defun pgg-pgp5-sign-region (start end &optional clearsign passphrase)
-  "Make detached signature from text between START and END."
+  "This function is for internal use only.
+
+Make detached signature from text between START and END."
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
 	 (passphrase
 	  (or passphrase
@@ -206,7 +217,9 @@
 	       passphrase)))))))
 
 (defun pgg-pgp5-verify-region (start end &optional signature)
-  "Verify region between START and END as the detached signature SIGNATURE."
+  "This function is for internal use only.
+
+Verify region between START and END as the detached signature SIGNATURE."
   (let ((orig-file (pgg-make-temp-file "pgg"))
 	(args '("+verbose=1" "+batchmode=1" "+language=us"))
 	(orig-mode (default-file-modes)))
@@ -233,7 +246,9 @@
 	nil))))
 
 (defun pgg-pgp5-insert-key ()
-  "Insert public key at point."
+  "This function is for internal use only.
+
+Insert public key at point."
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
 	 (args
 	  (list "+verbose=1" "+batchmode=1" "+language=us" "-x"
@@ -242,7 +257,9 @@
     (insert-buffer-substring pgg-output-buffer)))
 
 (defun pgg-pgp5-snarf-keys-region (start end)
-  "Add all public keys in region between START and END to the keyring."
+  "This function is for internal use only.
+
+Add all public keys in region between START and END to the keyring."
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
 	 (key-file (pgg-make-temp-file "pgg"))
 	 (args
Index: lisp/pgg.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/pgg.el,v
retrieving revision 7.10
diff -u -r7.10 pgg.el
--- lisp/pgg.el	19 Jan 2006 11:53:12 -0000	7.10
+++ lisp/pgg.el	7 Apr 2006 08:07:27 -0000
@@ -33,7 +33,6 @@
 (require 'pgg-parse)
 (require 'password)
 
-;; Don't merge these two `eval-when-compile's.
 (eval-when-compile
   (require 'cl))
 
@@ -190,8 +189,8 @@
 
 If optional argument SIGN is non-nil, do a combined sign and encrypt.
 
-If optional PASSPHRASE is not specified, it will be obtained from the
-passphrase cache or user."
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (interactive
    (list (region-beginning)(region-end)
 	 (split-string (read-string "Recipients: ") "[ \t,]+")))
@@ -245,8 +244,8 @@
 If optional arguments START and END are specified, only encrypt within
 the region.
 
-If optional PASSPHRASE is not specified, it will be obtained from the
-passphrase cache or user."
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (interactive (list (split-string (read-string "Recipients: ") "[ \t,]+")))
   (let* ((start (or start (point-min)))
 	 (end (or end (point-max)))
@@ -259,8 +258,8 @@
 (defun pgg-decrypt-region (start end &optional passphrase)
   "Decrypt the current region between START and END.
 
-If optional PASSPHRASE is not specified, it will be obtained from the
-passphrase cache or user."
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (interactive "r")
   (let* ((buf (current-buffer))
 	 (status
@@ -278,8 +277,8 @@
 If optional arguments START and END are specified, only decrypt within
 the region.
 
-If optional PASSPHRASE is not specified, it will be obtained from the
-passphrase cache or user."
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (interactive "")
   (let* ((start (or start (point-min)))
 	 (end (or end (point-max)))
@@ -298,8 +297,8 @@
 If this function is called interactively, CLEARTEXT is enabled
 and the the output is displayed.
 
-If optional PASSPHRASE is not specified, it will be obtained from the
-passphrase cache or user."
+Obsolete feature: if optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (interactive "r")
   (let ((status (pgg-save-coding-system start end
 		  (pgg-invoke "sign-region" (or pgg-scheme pgg-default-scheme)
@@ -323,8 +322,8 @@
 If this function is called interactively, CLEARTEXT is enabled
 and the the output is displayed.
 
-If optional PASSPHRASE is not specified, it will be obtained from the
-passphrase cache or user."
+Obsolete feature: If optional PASSPHRASE is not specified, it will be
+obtained from the passphrase cache or user."
   (interactive "")
   (let* ((start (or start (point-min)))
 	 (end (or end (point-max)))
@@ -338,8 +337,8 @@
 ;;;###autoload
 (defun pgg-verify-region (start end &optional signature fetch)
   "Verify the current region between START and END.
-If the optional 3rd argument SIGNATURE is non-nil, it is treated as
-the detached signature of the current region.
+If the optional 3rd argument SIGNATURE is non-nil, it points to the file
+containing detached signature of the current region.
 
 If the optional 4th argument FETCH is non-nil, we attempt to fetch the
 signer's public key from `pgg-default-keyserver-address'."
@@ -381,8 +380,8 @@
 ;;;###autoload
 (defun pgg-verify (&optional signature fetch start end)
   "Verify the current buffer.
-If the optional argument SIGNATURE is non-nil, it is treated as
-the detached signature of the current region.
+If the optional argument SIGNATURE is non-nil, it points to the file
+containing the detached signature of the current region.
 If the optional argument FETCH is non-nil, we attempt to fetch the
 signer's public key from `pgg-default-keyserver-address'.
 If optional arguments START and END are specified, only verify data
@@ -422,6 +421,10 @@
 
 (defun pgg-lookup-key (string &optional type)
   (pgg-invoke "lookup-key" (or pgg-scheme pgg-default-scheme) string type))
+
+;;;###autoload
+(defun pgg-list-keys (name &optional secret)
+  (pgg-invoke "list-keys" (or pgg-scheme pgg-default-scheme) name secret))
 
 (defvar pgg-insert-url-function  (function pgg-insert-url-with-w3))
 

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Bad usage of pgg-gpg-* functions in allout.el
  2006-04-07  3:46           ` Bad usage of pgg-gpg-* functions in allout.el Daiki Ueno
@ 2006-04-07  9:43             ` Daiki Ueno
  0 siblings, 0 replies; 7+ messages in thread
From: Daiki Ueno @ 2006-04-07  9:43 UTC (permalink / raw)
  Cc: ding, emacs-devel

>>>>> In <2595ece8-1a2b-48e5-a905-b37bd890ecae_-_@well-done.deisui.org> 
>>>>>	Daiki Ueno <ueno@unixuser.org> wrote:
> >>>>> In <2cd46e7f0604061550j44c97f68v4c6cffda79a4e0ce@mail.gmail.com> 
> >>>>>	"Ken Manheimer" <ken.manheimer@gmail.com> wrote:
> > thank you!  allout's encryption seems to be working with your reversion.

> Aside from the reversion of pgg-gpg.el, when I looked into allout.el's
> encryption stuff, I found that 4 undocumented non-interface functions
> of pgg-gpg are used:

> pgg-gpg-lookup-key-owner

> pgg-gpg-lookup-key-owner needs to be implemented as an interface
> function.  I'm now working on this.

>>>>> In <5451ce4a-1627-439f-9cba-308911539eae@well-done.deisui.org> 
>>>>>	Daiki Ueno <ueno@unixuser.org> wrote:
> Patch from Gnus' trunk is attached.  Major changes are listed below.

> * Added new interface function pgg-list-keys.  This function returns
> more information about keys than pgg-lookup-key.  For example:

With this function, a function which does the same thing as
pgg-gpg-lookup-key-owner can be implemented.

(defun allout-lookup-key-owner (string &optional all)
  "Search keys associated with STRING and return owner of identified key.

The value may be just the bare key id, or it may be a combination of the
user name associated with the key and the key id, with the key id enclosed
in \"<...>\" angle brackets.

Optional ALL non-nil means search all keys, including secret keys."
  (let ((keys (pgg-gpg-list-keys string all))
	entry)
    (while keys
      (setq entry (assq 'user-id (assq 'uid (car keys))))
      (if entry
	  (setq keys nil)
	(setq keys (cdr keys))))
    (cdr entry)))

(allout-lookup-key-owner "ueno")
=> "Daiki Ueno <ueno@unixuser.org>"

Regards,
-- 
Daiki Ueno

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pgg-gpg stalls
  2006-04-06 19:10       ` Romain Francoise
  2006-04-06 22:50         ` Ken Manheimer
@ 2006-04-07 12:46         ` Thomas Baumann
  1 sibling, 0 replies; 7+ messages in thread
From: Thomas Baumann @ 2006-04-07 12:46 UTC (permalink / raw)
  Cc: emacs-pretest-bug, Ken Manheimer, Daiki Ueno, ding, Reiner Steib

just tested with today's cvs emacs:

signing emails does work again, but checking signatures is not possible:

open an email with signature
[mouse-1] on [[PGP Signed Part:Undecided]]

= everything between [[PGP Signed Part:Undecided]] and [[End of PGP
Signed Part]] disappears and there is no change to the buttons....

this works with pgg-gpg from February...

gpg (GnuPG) 1.4.2

Thomas

Romain Francoise <romain@orebokech.com> wrote:

> Reiner Steib <reinersteib+gmane@imap.cc> writes:
> 
> > I wasn't not sure if `allout.el' depends on the symmetric encryption
> > features, so I didn't revert it in Emacs CVS.
> 
> Actually it's the other way around, the recent changes to PGG broke
> allout's encryption code, so reverting them makes allout work again.
> 
> See:
> 
> | From: "Ken Manheimer" <ken.manheimer@gmail.com>
> | Subject: Re: Small patch to enable use of gpg-agent with pgg
> | Message-ID: <2cd46e7f0604011630r6388edackc4c7ef21b92ecaa7@mail.gmail.com>
> | Date: Sat, 1 Apr 2006 19:30:04 -0500
> 
> -- 
> Romain Francoise <romain@orebokech.com> | The sea! the sea! the open
> it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
>                                         | ever free! --Bryan W. Procter
> 

-- 
Dr. Thomas Baumann

Institute of Hydrochemistry  
Technische Universitaet Muenchen
Marchioninistr. 17
D-81377 Muenchen
Voice: +49 89 2180-78234
Fax:   +49 89 2180-78255
http://www.ws.chemie.tu-muenchen.de/hydrogeo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-04-07 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-07  8:09 PGG updates Daiki Ueno
     [not found] ` <27877.1144257571@norvel.baumann-gauting.site>
     [not found]   ` <87odze8tth.fsf@pacem.orebokech.com>
2006-04-06 18:47     ` pgg-gpg stalls Reiner Steib
2006-04-06 19:10       ` Romain Francoise
2006-04-06 22:50         ` Ken Manheimer
2006-04-07  3:46           ` Bad usage of pgg-gpg-* functions in allout.el Daiki Ueno
2006-04-07  9:43             ` Daiki Ueno
2006-04-07 12:46         ` pgg-gpg stalls Thomas Baumann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).