aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Josefsson2006-03-22 16:09:16 +0000
committerSimon Josefsson2006-03-22 16:09:16 +0000
commit4803386d1cae23a22f6b5aa9b6417e65b7f06d50 (patch)
treec6c25644ee8eb79faf69b060c5a344a2259fe6d3
parentd63cd76657e12b92a5d7736a15bc9b97a7f9990e (diff)
downloademacs-4803386d1cae23a22f6b5aa9b6417e65b7f06d50.tar.gz
emacs-4803386d1cae23a22f6b5aa9b6417e65b7f06d50.zip
2006-03-22 Simon Josefsson <jas@extundo.com>
* pgg-gpg.el (pgg-gpg-use-agent): Disable by default. (pgg-gpg-update-agent): New function. (pgg-gpg-use-agent-p): New function. (pgg-gpg-process-region, pgg-gpg-encrypt-region) (pgg-gpg-encrypt-symmetric-region, pgg-gpg-decrypt-region) (pgg-gpg-sign-region): Use it.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/pgg-gpg.el41
2 files changed, 39 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index acfc4975c54..658f13fd5e1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12006-03-22 Simon Josefsson <jas@extundo.com>
2
3 * pgg-gpg.el (pgg-gpg-use-agent): Disable by default.
4 (pgg-gpg-update-agent): New function.
5 (pgg-gpg-use-agent-p): New function.
6 (pgg-gpg-process-region, pgg-gpg-encrypt-region)
7 (pgg-gpg-encrypt-symmetric-region, pgg-gpg-decrypt-region)
8 (pgg-gpg-sign-region): Use it.
9
12006-03-21 Chong Yidong <cyd@stupidchicken.com> 102006-03-21 Chong Yidong <cyd@stupidchicken.com>
2 11
3 * cus-edit.el (custom-face-set): Call custom-push-theme before 12 * cus-edit.el (custom-face-set): Call custom-push-theme before
diff --git a/lisp/pgg-gpg.el b/lisp/pgg-gpg.el
index a9608b7f4f2..eefc569fd04 100644
--- a/lisp/pgg-gpg.el
+++ b/lisp/pgg-gpg.el
@@ -4,7 +4,8 @@
4;; 2005, 2006 Free Software Foundation, Inc. 4;; 2005, 2006 Free Software Foundation, Inc.
5 5
6;; Author: Daiki Ueno <ueno@unixuser.org> 6;; Author: Daiki Ueno <ueno@unixuser.org>
7;; Symmetric encryption added by: Sascha Wilde <wilde@sha-bang.de> 7;; Symmetric encryption and gpg-agent support added by:
8;; Sascha Wilde <wilde@sha-bang.de>
8;; Created: 1999/10/28 9;; Created: 1999/10/28
9;; Keywords: PGP, OpenPGP, GnuPG 10;; Keywords: PGP, OpenPGP, GnuPG
10 11
@@ -51,10 +52,8 @@
51 :type '(choice (const :tag "New `--recipient' option" "--recipient") 52 :type '(choice (const :tag "New `--recipient' option" "--recipient")
52 (const :tag "Old `--remote-user' option" "--remote-user"))) 53 (const :tag "Old `--remote-user' option" "--remote-user")))
53 54
54(defcustom pgg-gpg-use-agent (if (getenv "GPG_AGENT_INFO") t nil) 55(defcustom pgg-gpg-use-agent nil
55 "Whether to use gnupg agent for key caching. 56 "Whether to use gnupg agent for key caching."
56By default, it will be enabled iff the environment variable
57\"GPG_AGENT_INFO\" is set."
58 :group 'pgg-gpg 57 :group 'pgg-gpg
59 :type 'boolean) 58 :type 'boolean)
60 59
@@ -62,10 +61,11 @@ By default, it will be enabled iff the environment variable
62 "GnuPG ID of your default identity.") 61 "GnuPG ID of your default identity.")
63 62
64(defun pgg-gpg-process-region (start end passphrase program args) 63(defun pgg-gpg-process-region (start end passphrase program args)
65 (let* ((output-file-name (pgg-make-temp-file "pgg-output")) 64 (let* ((use-agent (pgg-gpg-use-agent-p))
65 (output-file-name (pgg-make-temp-file "pgg-output"))
66 (args 66 (args
67 `("--status-fd" "2" 67 `("--status-fd" "2"
68 ,@(if pgg-gpg-use-agent '("--use-agent") 68 ,@(if use-agent '("--use-agent")
69 (if passphrase '("--passphrase-fd" "0"))) 69 (if passphrase '("--passphrase-fd" "0")))
70 "--yes" ; overwrite 70 "--yes" ; overwrite
71 "--output" ,output-file-name 71 "--output" ,output-file-name
@@ -189,7 +189,7 @@ If optional PASSPHRASE is not specified, it will be obtained from the
189passphrase cache or user." 189passphrase cache or user."
190 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id)) 190 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
191 (passphrase (or passphrase 191 (passphrase (or passphrase
192 (when (and sign (not pgg-gpg-use-agent)) 192 (when (and sign (not (pgg-gpg-use-agent-p)))
193 (pgg-read-passphrase 193 (pgg-read-passphrase
194 (format "GnuPG passphrase for %s: " 194 (format "GnuPG passphrase for %s: "
195 pgg-gpg-user-id) 195 pgg-gpg-user-id)
@@ -221,7 +221,7 @@ passphrase cache or user."
221If optional PASSPHRASE is not specified, it will be obtained from the 221If optional PASSPHRASE is not specified, it will be obtained from the
222passphrase cache or user." 222passphrase cache or user."
223 (let* ((passphrase (or passphrase 223 (let* ((passphrase (or passphrase
224 (when (not pgg-gpg-use-agent) 224 (when (not (pgg-gpg-use-agent-p))
225 (pgg-read-passphrase 225 (pgg-read-passphrase
226 "GnuPG passphrase for symmetric encryption: ")))) 226 "GnuPG passphrase for symmetric encryption: "))))
227 (args 227 (args
@@ -250,7 +250,7 @@ passphrase cache or user."
250 (pgg-gpg-user-id (or key-id key 250 (pgg-gpg-user-id (or key-id key
251 pgg-gpg-user-id pgg-default-user-id)) 251 pgg-gpg-user-id pgg-default-user-id))
252 (passphrase (or passphrase 252 (passphrase (or passphrase
253 (when (not pgg-gpg-use-agent) 253 (when (not (pgg-gpg-use-agent-p))
254 (pgg-read-passphrase 254 (pgg-read-passphrase
255 (format (if (pgg-gpg-symmetric-key-p message-keys) 255 (format (if (pgg-gpg-symmetric-key-p message-keys)
256 "Passphrase for symmetric decryption: " 256 "Passphrase for symmetric decryption: "
@@ -286,7 +286,7 @@ passphrase cache or user."
286 "Make detached signature from text between START and END." 286 "Make detached signature from text between START and END."
287 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id)) 287 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
288 (passphrase (or passphrase 288 (passphrase (or passphrase
289 (when (not pgg-gpg-use-agent) 289 (when (not (pgg-gpg-use-agent-p))
290 (pgg-read-passphrase 290 (pgg-read-passphrase
291 (format "GnuPG passphrase for %s: " 291 (format "GnuPG passphrase for %s: "
292 pgg-gpg-user-id) 292 pgg-gpg-user-id)
@@ -356,6 +356,25 @@ passphrase cache or user."
356 (append-to-buffer pgg-output-buffer (point-min)(point-max)) 356 (append-to-buffer pgg-output-buffer (point-min)(point-max))
357 (pgg-process-when-success))) 357 (pgg-process-when-success)))
358 358
359(defun pgg-gpg-update-agent ()
360 "Try to connet to gpg-agent and send UPDATESTARTUPTTY."
361 (let* ((agent-info (getenv "GPG_AGENT_INFO"))
362 (socket (and agent-info
363 (string-match "^\\([^:]*\\)" agent-info)
364 (match-string 1 agent-info)))
365 (conn (and socket
366 (make-network-process :name "gpg-agent-process"
367 :host 'local :family 'local
368 :service socket))))
369 (when (and conn (eq (process-status conn) 'open))
370 (process-send-string conn "UPDATESTARTUPTTY\n")
371 (delete-process conn)
372 t)))
373
374(defun pgg-gpg-use-agent-p ()
375 "Return t if `pgg-gpg-use-agent' is t and gpg-agent is available."
376 (and pgg-gpg-use-agent (pgg-gpg-update-agent)))
377
359(provide 'pgg-gpg) 378(provide 'pgg-gpg)
360 379
361;;; arch-tag: 2aa5d5d8-93a0-4865-9312-33e29830e000 380;;; arch-tag: 2aa5d5d8-93a0-4865-9312-33e29830e000