aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Josefsson2006-03-21 14:27:05 +0000
committerSimon Josefsson2006-03-21 14:27:05 +0000
commite563e53b5c7d7631d5f40dd1ed12933b78203c46 (patch)
treee8596e2f8ce577cb5403ad340b34c8c263cb3662
parentc0434d3b46c55c7128b2f80e7b908348b22c1eb8 (diff)
downloademacs-e563e53b5c7d7631d5f40dd1ed12933b78203c46.tar.gz
emacs-e563e53b5c7d7631d5f40dd1ed12933b78203c46.zip
2006-03-21 Simon Josefsson <jas@extundo.com>
* pgg-gpg.el: Ideas below based on patch from Sascha Wilde <wilde@sha-bang.de>. (pgg-gpg-use-agent): New variable. (pgg-gpg-process-region): Use it. (pgg-gpg-encrypt-region): Likewise. (pgg-gpg-encrypt-symmetric-region): Likewise. (pgg-gpg-decrypt-region): Likewise. (pgg-gpg-sign-region): Likewise. (pgg-gpg-possibly-cache-passphrase): Don't cache a nil password.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/pgg-gpg.el49
2 files changed, 43 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4c325e968ca..22a05486c9e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12006-03-21 Simon Josefsson <jas@extundo.com>
2
3 * pgg-gpg.el: Ideas below based on patch from Sascha Wilde
4 <wilde@sha-bang.de>.
5 (pgg-gpg-use-agent): New variable.
6 (pgg-gpg-process-region): Use it.
7 (pgg-gpg-encrypt-region): Likewise.
8 (pgg-gpg-encrypt-symmetric-region): Likewise.
9 (pgg-gpg-decrypt-region): Likewise.
10 (pgg-gpg-sign-region): Likewise.
11 (pgg-gpg-possibly-cache-passphrase): Don't cache a nil password.
12
12006-03-21 Carsten Dominik <dominik@science.uva.nl> 132006-03-21 Carsten Dominik <dominik@science.uva.nl>
2 14
3 * textmodes/org.el: (org-open-at-point): Fixed bug in wiki-style 15 * textmodes/org.el: (org-open-at-point): Fixed bug in wiki-style
diff --git a/lisp/pgg-gpg.el b/lisp/pgg-gpg.el
index 0c9f45ab5b9..28512dce8fc 100644
--- a/lisp/pgg-gpg.el
+++ b/lisp/pgg-gpg.el
@@ -51,6 +51,13 @@
51 :type '(choice (const :tag "New `--recipient' option" "--recipient") 51 :type '(choice (const :tag "New `--recipient' option" "--recipient")
52 (const :tag "Old `--remote-user' option" "--remote-user"))) 52 (const :tag "Old `--remote-user' option" "--remote-user")))
53 53
54(defcustom pgg-gpg-use-agent (if (getenv "GPG_AGENT_INFO") t nil)
55 "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
59 :type 'boolean)
60
54(defvar pgg-gpg-user-id nil 61(defvar pgg-gpg-user-id nil
55 "GnuPG ID of your default identity.") 62 "GnuPG ID of your default identity.")
56 63
@@ -58,7 +65,8 @@
58 (let* ((output-file-name (pgg-make-temp-file "pgg-output")) 65 (let* ((output-file-name (pgg-make-temp-file "pgg-output"))
59 (args 66 (args
60 `("--status-fd" "2" 67 `("--status-fd" "2"
61 ,@(if passphrase '("--passphrase-fd" "0")) 68 ,@(if pgg-gpg-use-agent '("--use-agent")
69 (if passphrase '("--passphrase-fd" "0")))
62 "--yes" ; overwrite 70 "--yes" ; overwrite
63 "--output" ,output-file-name 71 "--output" ,output-file-name
64 ,@pgg-gpg-extra-args ,@args)) 72 ,@pgg-gpg-extra-args ,@args))
@@ -100,7 +108,8 @@
100 (set-default-file-modes orig-mode)))) 108 (set-default-file-modes orig-mode))))
101 109
102(defun pgg-gpg-possibly-cache-passphrase (passphrase &optional key notruncate) 110(defun pgg-gpg-possibly-cache-passphrase (passphrase &optional key notruncate)
103 (if (and pgg-cache-passphrase 111 (if (and passphrase
112 pgg-cache-passphrase
104 (progn 113 (progn
105 (goto-char (point-min)) 114 (goto-char (point-min))
106 (re-search-forward "^\\[GNUPG:] \\(GOOD_PASSPHRASE\\>\\)\\|\\(SIG_CREATED\\)" nil t))) 115 (re-search-forward "^\\[GNUPG:] \\(GOOD_PASSPHRASE\\>\\)\\|\\(SIG_CREATED\\)" nil t)))
@@ -182,11 +191,11 @@ If optional PASSPHRASE is not specified, it will be obtained from the
182passphrase cache or user." 191passphrase cache or user."
183 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id)) 192 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
184 (passphrase (or passphrase 193 (passphrase (or passphrase
185 (when sign 194 (when (and sign (not pgg-gpg-use-agent))
186 (pgg-read-passphrase 195 (pgg-read-passphrase
187 (format "GnuPG passphrase for %s: " 196 (format "GnuPG passphrase for %s: "
188 pgg-gpg-user-id) 197 pgg-gpg-user-id)
189 pgg-gpg-user-id)))) 198 pgg-gpg-user-id))))
190 (args 199 (args
191 (append 200 (append
192 (list "--batch" "--armor" "--always-trust" "--encrypt") 201 (list "--batch" "--armor" "--always-trust" "--encrypt")
@@ -214,8 +223,9 @@ passphrase cache or user."
214If optional PASSPHRASE is not specified, it will be obtained from the 223If optional PASSPHRASE is not specified, it will be obtained from the
215passphrase cache or user." 224passphrase cache or user."
216 (let* ((passphrase (or passphrase 225 (let* ((passphrase (or passphrase
217 (pgg-read-passphrase 226 (when (not pgg-gpg-use-agent)
218 "GnuPG passphrase for symmetric encryption: "))) 227 (pgg-read-passphrase
228 "GnuPG passphrase for symmetric encryption: "))))
219 (args 229 (args
220 (append (list "--batch" "--armor" "--symmetric" ) 230 (append (list "--batch" "--armor" "--symmetric" )
221 (if pgg-text-mode (list "--textmode"))))) 231 (if pgg-text-mode (list "--textmode")))))
@@ -242,12 +252,13 @@ passphrase cache or user."
242 (pgg-gpg-user-id (or key-id key 252 (pgg-gpg-user-id (or key-id key
243 pgg-gpg-user-id pgg-default-user-id)) 253 pgg-gpg-user-id pgg-default-user-id))
244 (passphrase (or passphrase 254 (passphrase (or passphrase
245 (pgg-read-passphrase 255 (when (not pgg-gpg-use-agent)
246 (format (if (pgg-gpg-symmetric-key-p message-keys) 256 (pgg-read-passphrase
247 "Passphrase for symmetric decryption: " 257 (format (if (pgg-gpg-symmetric-key-p message-keys)
248 "GnuPG passphrase for %s: ") 258 "Passphrase for symmetric decryption: "
249 (or key-owner "??")) 259 "GnuPG passphrase for %s: ")
250 pgg-gpg-user-id))) 260 (or key-owner "??"))
261 pgg-gpg-user-id))))
251 (args '("--batch" "--decrypt"))) 262 (args '("--batch" "--decrypt")))
252 (pgg-gpg-process-region start end passphrase pgg-gpg-program args) 263 (pgg-gpg-process-region start end passphrase pgg-gpg-program args)
253 (with-current-buffer pgg-errors-buffer 264 (with-current-buffer pgg-errors-buffer
@@ -277,9 +288,11 @@ passphrase cache or user."
277 "Make detached signature from text between START and END." 288 "Make detached signature from text between START and END."
278 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id)) 289 (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
279 (passphrase (or passphrase 290 (passphrase (or passphrase
280 (pgg-read-passphrase 291 (when (not pgg-gpg-use-agent)
281 (format "GnuPG passphrase for %s: " pgg-gpg-user-id) 292 (pgg-read-passphrase
282 pgg-gpg-user-id))) 293 (format "GnuPG passphrase for %s: "
294 pgg-gpg-user-id)
295 pgg-gpg-user-id))))
283 (args 296 (args
284 (append (list (if cleartext "--clearsign" "--detach-sign") 297 (append (list (if cleartext "--clearsign" "--detach-sign")
285 "--armor" "--batch" "--verbose" 298 "--armor" "--batch" "--verbose"