]> code.delx.au - gnu-emacs/commitdiff
epg: Automatically start pinentry server
authorDaiki Ueno <ueno@gnu.org>
Thu, 16 Jul 2015 06:43:03 +0000 (15:43 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 16 Jul 2015 06:43:03 +0000 (15:43 +0900)
* epg-config.el (epg-gpgconf-program): New variable.
* epg.el (epg--start): Call `pinentry-start' if
allow-emacs-pinentry is set in ~/.gnupg/gpg-agent.conf.

lisp/epg-config.el
lisp/epg.el

index 10f0dd3f4bf79b781d237e1365957d8abc28613d..db2951306d0536ca6e4a9a6d45fcd43edf271b8a 100644 (file)
   :group 'epg
   :type 'string)
 
+(defcustom epg-gpgconf-program "gpgconf"
+  "The `gpgconf' executable."
+  :group 'epg
+  :type 'string)
+
 (defcustom epg-gpg-home-directory nil
   "The directory which contains the configuration files of `epg-gpg-program'."
   :group 'epg
index b3d39bb85053f72e230261368716ac3abe6f9b0c..4ba96272aaef2733d57c362f223ab5b1cb816170 100644 (file)
@@ -602,6 +602,16 @@ callback data (if any)."
       (setq process-environment
            (cons (concat "GPG_TTY=" terminal-name)
                  (cons "TERM=xterm" process-environment))))
+    ;; Start the Emacs Pinentry server if allow-emacs-pinentry is set
+    ;; in ~/.gnupg/gpg-agent.conf.
+    (when (and (fboundp 'pinentry-start)
+               (with-temp-buffer
+                 (when (= (call-process epg-gpgconf-program nil t nil
+                                        "--list-options" "gpg-agent")
+                          0)
+                   (goto-char (point-min))
+                   (re-search-forward "^allow-emacs-pinentry:.*:1$" nil t))))
+      (pinentry-start))
     (setq process-environment
           (cons (format "INSIDE_EMACS=%s,epg" emacs-version)
                 process-environment))