From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.bugs Subject: bug#469: pgg-gpg.el - pgg-gpg-process-region timing problem Date: Mon, 23 Jun 2008 10:43:05 +0200 Message-ID: <87r6ao8rty.fsf__23078.6490873017$1214277977$gmane$org@ambire.localdomain> References: <2cd46e7f0806221037h6d16839bp567eb5b901313375@mail.gmail.com> <87zlpc8t00.fsf@ambire.localdomain> Reply-To: Thien-Thi Nguyen , 469@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214277926 8264 80.91.229.12 (24 Jun 2008 03:25:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Jun 2008 03:25:26 +0000 (UTC) Cc: wilde@sha-bang.de, emacs-pretest-bug@gnu.org, ueno@unixuser.org, emacs-devel To: "ken manheimer" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 24 05:26:10 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KAzAX-00026X-5w for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 Jun 2008 05:26:09 +0200 Original-Received: from localhost ([127.0.0.1]:53645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KAz9h-0004gX-Q0 for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 Jun 2008 23:25:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KAi19-0008NR-EK for bug-gnu-emacs@gnu.org; Mon, 23 Jun 2008 05:07:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KAi16-0008M5-IU for bug-gnu-emacs@gnu.org; Mon, 23 Jun 2008 05:07:17 -0400 Original-Received: from [199.232.76.173] (port=37170 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KAi15-0008Lr-Fq for bug-gnu-emacs@gnu.org; Mon, 23 Jun 2008 05:07:15 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:36570) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KAi13-0005np-Uo for bug-gnu-emacs@gnu.org; Mon, 23 Jun 2008 05:07:14 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5N97ATv027294; Mon, 23 Jun 2008 02:07:11 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m5N8t51a023236; Mon, 23 Jun 2008 01:55:05 -0700 X-Loop: don@donarmstrong.com Resent-From: Thien-Thi Nguyen Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Mon, 23 Jun 2008 08:55:05 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 469 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.121421076721873 (code B ref -1); Mon, 23 Jun 2008 08:55:05 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 23 Jun 2008 08:46:07 +0000 Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5N8k220021867 for ; Mon, 23 Jun 2008 01:46:04 -0700 Original-Received: from mail.gnu.org ([199.232.76.166]:40256 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1KAhgT-0000Lz-JU for emacs-pretest-bug@gnu.org; Mon, 23 Jun 2008 04:45:57 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1KAhgT-0004zt-ND for emacs-pretest-bug@gnu.org; Mon, 23 Jun 2008 04:46:00 -0400 Original-Received: from [151.61.141.75] (port=33978 helo=ambire.localdomain) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KAhgS-0004yL-Hy; Mon, 23 Jun 2008 04:45:57 -0400 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1KAhdh-0001aU-4g; Mon, 23 Jun 2008 10:43:05 +0200 In-Reply-To: <87zlpc8t00.fsf@ambire.localdomain> (Thien-Thi Nguyen's message of "Mon, 23 Jun 2008 10:17:51 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-Greylist: delayed 1512 seconds by postgrey-1.27 at monty-python; Mon, 23 Jun 2008 04:45:54 EDT X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Mon, 23 Jun 2008 05:07:16 -0400 X-Mailman-Approved-At: Mon, 23 Jun 2008 23:25:12 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:18510 Archived-At: ChangeLog entry: Use process sentinel to monitor gpg subprocess status. * pgg-gpg.el (pgg-gpg-process-region): Fix omission bug: Use process sentinel to update process status and exit-status. Reported by ken manheimer . patch: *** pgg-gpg.el 6 May 2008 07:57:46 -0000 1.27 --- pgg-gpg.el 23 Jun 2008 08:40:50 -0000 *************** *** 70,111 **** ,@pgg-gpg-extra-args ,@args)) (output-buffer pgg-output-buffer) (errors-buffer pgg-errors-buffer) ! (orig-mode (default-file-modes)) ! (process-connection-type nil) ! (inhibit-redisplay t) ! process status exit-status ! passphrase-with-newline ! encoded-passphrase-with-new-line) (with-current-buffer (get-buffer-create errors-buffer) (buffer-disable-undo) (erase-buffer)) (unwind-protect ! (progn (set-default-file-modes 448) ! (let ((coding-system-for-write 'binary)) ! (setq process ! (apply #'start-process "*GnuPG*" errors-buffer ! program args))) ! (set-process-sentinel process #'ignore) (when passphrase ! (setq passphrase-with-newline (concat passphrase "\n")) ! (if pgg-passphrase-coding-system ! (progn ! (setq encoded-passphrase-with-new-line (encode-coding-string ! passphrase-with-newline ! (coding-system-change-eol-conversion ! pgg-passphrase-coding-system 'unix))) ! (pgg-clear-string passphrase-with-newline)) ! (setq encoded-passphrase-with-new-line passphrase-with-newline ! passphrase-with-newline nil)) ! (process-send-string process encoded-passphrase-with-new-line)) (process-send-region process start end) (process-send-eof process) ! (while (eq 'run (process-status process)) (accept-process-output process 5)) - (setq status (process-status process) - exit-status (process-exit-status process)) (delete-process process) (with-current-buffer (get-buffer-create output-buffer) (buffer-disable-undo) --- 70,104 ---- ,@pgg-gpg-extra-args ,@args)) (output-buffer pgg-output-buffer) (errors-buffer pgg-errors-buffer) ! (inhibit-redisplay t)) (with-current-buffer (get-buffer-create errors-buffer) (buffer-disable-undo) (erase-buffer)) (unwind-protect ! (let* ((coding-system-for-write 'binary) ! (process (let ((orig (default-file-modes))) (set-default-file-modes 448) ! (prog1 (apply #'start-process "*GnuPG*" ! errors-buffer program args) ! (set-default-file-modes orig)))) ! (status (process-status process)) ! exit-status) ! (set-process-sentinel ! process (lambda (process reason) ! (setq status (process-status process) ! exit-status (process-exit-status process)))) (when passphrase ! (process-send-string ! process (if pgg-passphrase-coding-system (encode-coding-string ! passphrase ! pgg-passphrase-coding-system) ! passphrase)) ! (process-send-string process "\n")) (process-send-region process start end) (process-send-eof process) ! (while (eq 'run status) (accept-process-output process 5)) (delete-process process) (with-current-buffer (get-buffer-create output-buffer) (buffer-disable-undo) *************** *** 120,134 **** (error "%s exited abnormally: '%s'" program exit-status)) (if (= 127 exit-status) (error "%s could not be found" program)))) - (if passphrase-with-newline - (pgg-clear-string passphrase-with-newline)) - (if encoded-passphrase-with-new-line - (pgg-clear-string encoded-passphrase-with-new-line)) - (if (and process (eq 'run (process-status process))) - (interrupt-process process)) (if (file-exists-p output-file-name) ! (delete-file output-file-name)) ! (set-default-file-modes orig-mode)))) (defun pgg-gpg-possibly-cache-passphrase (passphrase &optional key notruncate) (if (and passphrase --- 113,120 ---- (error "%s exited abnormally: '%s'" program exit-status)) (if (= 127 exit-status) (error "%s could not be found" program)))) (if (file-exists-p output-file-name) ! (delete-file output-file-name))))) (defun pgg-gpg-possibly-cache-passphrase (passphrase &optional key notruncate) (if (and passphrase