]> git.eshelyaron.com Git - emacs.git/commitdiff
epg: Utilize --pinentry-mode added in GnuPG 2.1
authorDaiki Ueno <ueno@gnu.org>
Fri, 7 Nov 2014 06:12:40 +0000 (15:12 +0900)
committerDaiki Ueno <ueno@gnu.org>
Fri, 7 Nov 2014 06:12:40 +0000 (15:12 +0900)
* epa.el (epa-pinentry-mode): New user option.
(epa-sign-file, epa-encrypt-file, epa-decrypt-region)
(epa-sign-region, epa-encrypt-region): Respect epa-pinentry-mode.
* epa-file.el (epa-file-insert-file-contents)
(epa-file-write-region): Respect epa-pinentry-mode.

lisp/ChangeLog
lisp/epa-file.el
lisp/epa.el

index d2eda8962955c81587fb1a4c89fc22e22b03fb6a..e3b453edc09dd522a7308065a71919493f95f60b 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-07  Daiki Ueno  <ueno@gnu.org>
+
+       * epa.el (epa-pinentry-mode): New user option.
+       (epa-sign-file, epa-encrypt-file, epa-decrypt-region)
+       (epa-sign-region, epa-encrypt-region): Respect epa-pinentry-mode.
+       * epa-file.el (epa-file-insert-file-contents)
+       (epa-file-write-region): Respect epa-pinentry-mode.
+
 2014-11-07  Daiki Ueno  <ueno@gnu.org>
 
        * epg.el (epg--list-keys-1): Ignore fields after the 15th field
index 759271bc4e8298f0c8f86cfffe18f21540ec21e4..e70bf6d13df22b7f5afc80b89b0a41f5e792f221 100644 (file)
@@ -144,6 +144,8 @@ encryption is used."
      context
      (cons #'epa-progress-callback-function
           (format "Decrypting %s" file)))
+    (if epa-pinentry-mode
+       (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
     (unwind-protect
        (progn
          (if replace
@@ -231,6 +233,8 @@ encryption is used."
      (cons #'epa-progress-callback-function
           (format "Encrypting %s" file)))
     (setf (epg-context-armor context) epa-armor)
+    (if epa-pinentry-mode
+       (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
     (condition-case error
        (setq string
              (epg-encrypt-string
index 6d20a190d9c84b1e8d94c4bd59b51be60486bb59..2814716e7a8a533b02dfa7fd2ab309bc6ff87ca1 100644 (file)
   :type 'integer
   :group 'epa)
 
+(defcustom epa-pinentry-mode nil
+  "The pinentry mode.
+
+GnuPG 2.1 or later has an option to control the behavior of
+Pinentry invocation.  Possible modes are: `ask', `cancel',
+`error', and `loopback'.  See the GnuPG manual for the meanings.
+
+In epa commands, a particularly useful mode is `loopback', which
+redirects all Pinentry queries to the caller, so Emacs can query
+passphrase through the minibuffer, instead of external Pinentry
+program."
+  :type '(choice (const nil)
+                (const ask)
+                (const cancel)
+                (const error)
+                (const loopback))
+  :group 'epa
+  :version "25.1")
+
 (defgroup epa-faces nil
   "Faces for epa-mode."
   :version "23.1"
@@ -764,6 +783,8 @@ If no one is selected, default secret key is used.  "
           #'epa-progress-callback-function
           (format "Signing %s..."
                   (file-name-nondirectory file))))
+    (if epa-pinentry-mode
+       (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
     (message "Signing %s..." (file-name-nondirectory file))
     (condition-case error
        (epg-sign-file context file signature mode)
@@ -794,6 +815,8 @@ If no one is selected, symmetric encryption will be performed.  ")))
           #'epa-progress-callback-function
           (format "Encrypting %s..."
                   (file-name-nondirectory file))))
+    (if epa-pinentry-mode
+       (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
     (message "Encrypting %s..." (file-name-nondirectory file))
     (condition-case error
        (epg-encrypt-file context file recipients cipher)
@@ -836,6 +859,8 @@ For example:
            (cons
             #'epa-progress-callback-function
             "Decrypting..."))
+      (if epa-pinentry-mode
+         (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
       (message "Decrypting...")
       (condition-case error
          (setq plain (epg-decrypt-string context (buffer-substring start end)))
@@ -1042,6 +1067,8 @@ If no one is selected, default secret key is used.  "
            (cons
             #'epa-progress-callback-function
             "Signing..."))
+      (if epa-pinentry-mode
+         (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
       (message "Signing...")
       (condition-case error
          (setq signature (epg-sign-string context
@@ -1130,6 +1157,8 @@ If no one is selected, symmetric encryption will be performed.  ")
            (cons
             #'epa-progress-callback-function
             "Encrypting..."))
+      (if epa-pinentry-mode
+         (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
       (message "Encrypting...")
       (condition-case error
          (setq cipher (epg-encrypt-string context
@@ -1298,6 +1327,8 @@ If no one is selected, default public key is exported.  ")))
 ;;          (cons
 ;;            #'epa-progress-callback-function
 ;;            "Signing keys..."))
+;;     (if epa-pinentry-mode
+;;        (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
 ;;     (message "Signing keys...")
 ;;     (epg-sign-keys context keys local)
 ;;     (message "Signing keys...done")))