[elpa] master 32bec2a 06/11: pinentry.el: Add debugging support

2018-01-16 Thread Nicolas Petton
branch: master
commit 32bec2a359771a5813cc17d4877f9172fdc103ec
Author: Daiki Ueno 
Commit: Nicolas Petton 

pinentry.el: Add debugging support

* packages/pinentry/pinentry.el (pinentry-debug): New variable.
(pinentry-debug-buffer): New variable.
(pinentry--process-filter): Send input to the debug buffer, if
`pinentry-debug' is set.
---
 packages/pinentry/pinentry.el | 9 +
 1 file changed, 9 insertions(+)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index d7161bb..eaa9fa4 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -63,6 +63,8 @@
   :type 'integer
   :group 'pinentry)
 
+(defvar pinentry-debug nil)
+(defvar pinentry-debug-buffer nil)
 (defvar pinentry--server-process nil)
 (defvar pinentry--connection-process-list nil)
 
@@ -293,6 +295,13 @@ Assuan protocol."
 (setq pinentry--read-point (point-min))
 (make-local-variable 'pinentry--labels
   (with-current-buffer (process-buffer process)
+(when pinentry-debug
+  (with-current-buffer
+  (or pinentry-debug-buffer
+  (setq pinentry-debug-buffer (generate-new-buffer
+   " *pinentry-debug*")))
+(goto-char (point-max))
+(insert input)))
 (save-excursion
   (goto-char (point-max))
   (insert input)



[elpa] master 7154adf 05/11: pinentry.el: Improve multiline prompt

2018-01-16 Thread Nicolas Petton
branch: master
commit 7154adfa564a44d6b4c7dd0fd6a6e579dd3daeef
Author: Daiki Ueno 
Commit: Nicolas Petton 

pinentry.el: Improve multiline prompt

* packages/pinentry/pinentry.el (pinentry--prompt): Simplify the interface.
(pinentry--process-filter): Use `pinentry--prompt' for CONFIRM
command.
---
 packages/pinentry/pinentry.el | 128 +++---
 1 file changed, 58 insertions(+), 70 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index 13a15c9..d7161bb 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -108,9 +108,18 @@ If local sockets are not supported, this is nil.")
   (setq truncate-lines t
buffer-read-only t))
 
-(defun pinentry--prompt (prompt short-prompt query-function &rest query-args)
-  (if (and (string-match "\n" prompt)
-   pinentry-popup-prompt-window)
+(defun pinentry--prompt (labels query-function &rest query-args)
+  (let ((desc (cdr (assq 'desc labels)))
+(error (cdr (assq 'error labels)))
+(prompt (cdr (assq 'prompt labels
+(when (string-match "[ \n]*\\'" prompt)
+  (setq prompt (concat
+(substring
+ prompt 0 (match-beginning 0)) " ")))
+(when error
+  (setq desc (concat "Error: " (propertize error 'face 'error)
+ "\n" desc)))
+(if (and desc pinentry-popup-prompt-window)
   (save-window-excursion
 (delete-other-windows)
(unless (and pinentry--prompt-buffer
@@ -122,7 +131,7 @@ If local sockets are not supported, this is nil.")
  (let ((inhibit-read-only t)
buffer-read-only)
(erase-buffer)
-   (insert prompt))
+   (insert desc))
  (pinentry-prompt-mode)
  (goto-char (point-min)))
(if (> (window-height)
@@ -135,13 +144,9 @@ If local sockets are not supported, this is nil.")
  (if (> (window-height) pinentry-prompt-window-height)
  (shrink-window (- (window-height)
 pinentry-prompt-window-height
-(prog1 (apply query-function short-prompt query-args)
+(prog1 (apply query-function prompt query-args)
   (quit-window)))
-(apply query-function
-   ;; Append a suffix to the prompt, which can be derived from
-   ;; SHORT-PROMPT.
-   (concat prompt (substring short-prompt -2))
-   query-args)))
+  (apply query-function (concat desc "\n" prompt) query-args
 
 ;;;###autoload
 (defun pinentry-start ()
@@ -312,29 +317,15 @@ Assuan protocol."
 (ignore-errors
   (process-send-string process "OK\n")))
 ("GETPIN"
- (let ((prompt
-(or (cdr (assq 'desc pinentry--labels))
-(cdr (assq 'prompt pinentry--labels))
-""))
-  (confirm (not (null (assq 'repeat pinentry--labels
-   entry)
-   (if (setq entry (assq 'error pinentry--labels))
-   (setq prompt (concat "Error: "
-(propertize
- (copy-sequence (cdr entry))
- 'face 'error)
-"\n"
-prompt)))
-   (if (setq entry (assq 'title pinentry--labels))
-   (setq prompt (format "[%s] %s"
-(cdr entry) prompt)))
-   (let (passphrase escaped-passphrase encoded-passphrase)
- (unwind-protect
- (condition-case nil
- (progn
-   (setq passphrase
-(pinentry--prompt prompt "Password: "
-   #'read-passwd confirm))
+ (let ((confirm (not (null (assq 'repeat pinentry--labels
+   passphrase escaped-passphrase encoded-passphrase)
+   (unwind-protect
+   (condition-case err
+   (progn
+ (setq passphrase
+   (pinentry--prompt
+pinentry--labels
+#'read-passwd confirm))
(setq escaped-passphrase
  (pinentry--escape-string
   passphrase))
@@ -345,7 +336,8 @@ Assuan protocol."
 (pinentry--send-data
  process encoded-passphrase)
 (process-send-string process "OK\n")))
-   (error
+

[elpa] master adc04d8 03/11: pinentry.el: Support external passphrase cache

2018-01-16 Thread Nicolas Petton
branch: master
commit adc04d81dd4f7b830cc68b2b8a18a1c2e0c28154
Author: Daiki Ueno 
Commit: Nicolas Petton 

pinentry.el: Support external passphrase cache

* packages/pinentry/pinentry.el (pinentry-use-secrets): New user option.
(pinentry--allow-external-password-cache): New local variable.
(pinentry--key-info): New local variable.
(secrets-enabled, secrets-search-items, secrets-get-secret):
Declare.
(pinentry--send-passphrase): New function, split from
`pinentry--process-filter'.
(pinentry--process-filter): Use secrets.el to retrieve passphrase
from login keyring.
---
 packages/pinentry/pinentry.el | 151 +-
 1 file changed, 105 insertions(+), 46 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index 13a15c9..aee8647 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -63,6 +63,11 @@
   :type 'integer
   :group 'pinentry)
 
+(defcustom pinentry-use-secrets nil
+  "If non-nil, use secrets.el to store passwords in login keyring."
+  :type 'boolean
+  :group 'pinentry)
+
 (defvar pinentry--server-process nil)
 (defvar pinentry--connection-process-list nil)
 
@@ -70,6 +75,10 @@
 (put 'pinentry-read-point 'permanent-local t)
 (defvar pinentry--read-point nil)
 (put 'pinentry--read-point 'permanent-local t)
+(defvar pinentry--allow-external-password-cache nil)
+(put 'pinentry--allow-external-password-cache 'permanent-local t)
+(defvar pinentry--key-info nil)
+(put 'pinentry--key-info 'permanent-local t)
 
 (defvar pinentry--prompt-buffer nil)
 
@@ -143,6 +152,10 @@ If local sockets are not supported, this is nil.")
(concat prompt (substring short-prompt -2))
query-args)))
 
+(defvar secrets-enabled)
+(declare-function secrets-search-items "secrets" (collection &rest attributes))
+(declare-function secrets-get-secret "secrets" (collection item))
+
 ;;;###autoload
 (defun pinentry-start ()
   "Start a Pinentry service.
@@ -277,6 +290,23 @@ Assuan protocol."
 (defun pinentry--send-error (process error)
   (process-send-string process (format "ERR %d %s\n" (car error) (cdr error
 
+(defun pinentry--send-passphrase (process passphrase)
+  (let (escaped-passphrase encoded-passphrase)
+(unwind-protect
+(condition-case nil
+(progn
+  (setq escaped-passphrase (pinentry--escape-string passphrase))
+  (setq encoded-passphrase (encode-coding-string escaped-passphrase
+ 'utf-8))
+  (pinentry--send-data process encoded-passphrase)
+  (process-send-string process "OK\n"))
+  (error
+   (pinentry--send-error process pinentry--error-cancelled)))
+  (if escaped-passphrase
+  (clear-string escaped-passphrase))
+  (if encoded-passphrase
+  (clear-string encoded-passphrase)
+
 (defun pinentry--process-filter (process input)
   (unless (buffer-live-p (process-buffer process))
 (let ((buffer (generate-new-buffer " *pinentry*")))
@@ -286,7 +316,9 @@ Assuan protocol."
 (set-buffer-multibyte nil))
 (make-local-variable 'pinentry--read-point)
 (setq pinentry--read-point (point-min))
-(make-local-variable 'pinentry--labels
+(make-local-variable 'pinentry--labels)
+(make-local-variable 'pinentry--allow-external-password-cache)
+(make-local-variable 'pinentry--key-info
   (with-current-buffer (process-buffer process)
 (save-excursion
   (goto-char (point-max))
@@ -311,52 +343,79 @@ Assuan protocol."
("NOP"
 (ignore-errors
   (process-send-string process "OK\n")))
+("OPTION"
+ (if (and pinentry-use-secrets
+  (require 'secrets)
+  secrets-enabled
+  (equal string "allow-external-password-cache"))
+ (setq pinentry--allow-external-password-cache t))
+ (ignore-errors
+  (process-send-string process "OK\n")))
+("SETKEYINFO"
+ (setq pinentry--key-info string)
+ (ignore-errors
+  (process-send-string process "OK\n")))
 ("GETPIN"
- (let ((prompt
-(or (cdr (assq 'desc pinentry--labels))
-(cdr (assq 'prompt pinentry--labels))
-""))
-  (confirm (not (null (assq 'repeat pinentry--labels
-   entry)
-   (if (setq entry (assq 'error pinentry--labels))
-   (setq prompt (concat "Error: "
-(propertize
- (copy-sequence (cdr entry))
- 'face 'error)
- 

[elpa] master efb0175 09/11: Change the default socket location for pinentry

2018-01-16 Thread Nicolas Petton
branch: master
commit efb0175fa60b481c001247be908c717033836f07
Author: Daiki Ueno 
Commit: Nicolas Petton 

Change the default socket location for pinentry

* packages/pinentry/pinentry.el: Require 'cl-lib for `cl-letf'.
(pinentry--socket-dir): Change the default from /tmp/emacsXXX to
~/.emacs.d/pinentry.
(pinentry-start): Change the file modes of the socket file to 0700.
This is just for extra safety since the parent directory is already
protected with `server-ensure-safe-dir'.
---
 packages/pinentry/pinentry.el | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index d7dca4a..9e23155 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -26,6 +26,9 @@
 ;; This package allows GnuPG passphrase to be prompted through the
 ;; minibuffer instead of graphical dialog.
 ;;
+;; This feature requires GnuPG 2.1.5 or later and Pinentry 0.9.5 or
+;; later, with the Emacs support compiled in.
+;;
 ;; To use, add "allow-emacs-pinentry" to "~/.gnupg/gpg-agent.conf",
 ;; reload the configuration with "gpgconf --reload gpg-agent", and
 ;; start the server with M-x pinentry-start.
@@ -38,17 +41,15 @@
 ;; where pinentry and Emacs communicate through a Unix domain socket
 ;; created at:
 ;;
-;;   ${TMPDIR-/tmp}/emacs$(id -u)/pinentry
-;;
-;; under the same directory which server.el uses.  The protocol is a
-;; subset of the Pinentry Assuan protocol described in (info
-;; "(pinentry) Protocol").
+;;   ~/.emacs.d/pinentry/pinentry
 ;;
-;; NOTE: As of August 2015, this feature requires newer versions of
-;; GnuPG (2.1.5+) and Pinentry (0.9.5+).
+;; The protocol is a subset of the Pinentry Assuan protocol described
+;; in (info "(pinentry) Protocol").
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defgroup pinentry nil
   "The Pinentry server"
   :version "25.1"
@@ -76,10 +77,7 @@
 
 (defvar pinentry--prompt-buffer nil)
 
-;; We use the same location as `server-socket-dir', when local sockets
-;; are supported.
-(defvar pinentry--socket-dir
-  (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))
+(defvar pinentry--socket-dir (locate-user-emacs-file "pinentry")
   "The directory in which to place the server socket.
 If local sockets are not supported, this is nil.")
 
@@ -172,16 +170,17 @@ will not be shown."
   (ignore-errors
 (let (delete-by-moving-to-trash)
   (delete-file server-file)))
-  (setq pinentry--server-process
-(make-network-process
- :name "pinentry"
- :server t
- :noquery t
- :sentinel #'pinentry--process-sentinel
- :filter #'pinentry--process-filter
- :coding 'no-conversion
- :family 'local
- :service server-file))
+  (cl-letf (((default-file-modes) ?\700))
+(setq pinentry--server-process
+  (make-network-process
+   :name "pinentry"
+   :server t
+   :noquery t
+   :sentinel #'pinentry--process-sentinel
+   :filter #'pinentry--process-filter
+   :coding 'no-conversion
+   :family 'local
+   :service server-file)))
   (process-put pinentry--server-process :server-file server-file
 
 (defun pinentry-stop ()



[elpa] master cd62826 08/11: Mention how to enable pinentry feature

2018-01-16 Thread Nicolas Petton
branch: master
commit cd62826257ff0eb1fe782cd57c02b95c1b734d3b
Author: Daiki Ueno 
Commit: Nicolas Petton 

Mention how to enable pinentry feature

* packages/pinentry/pinentry.el: Mention "gpgconf --reload gpg-agent".
---
 packages/pinentry/pinentry.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index 0037006..d7dca4a 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -26,7 +26,8 @@
 ;; This package allows GnuPG passphrase to be prompted through the
 ;; minibuffer instead of graphical dialog.
 ;;
-;; To use, add allow-emacs-pinentry to ~/.gnupg/gpg-agent.conf, and
+;; To use, add "allow-emacs-pinentry" to "~/.gnupg/gpg-agent.conf",
+;; reload the configuration with "gpgconf --reload gpg-agent", and
 ;; start the server with M-x pinentry-start.
 ;;
 ;; The actual communication path between the relevant components is



[elpa] master 2a2617f 04/11: Revert "pinentry.el: Support external passphrase cache"

2018-01-16 Thread Nicolas Petton
branch: master
commit 2a2617fe7c0d0b61284694bd43d23f25b35dbc73
Author: Daiki Ueno 
Commit: Nicolas Petton 

Revert "pinentry.el: Support external passphrase cache"

This reverts commit e086e55a664ec27fbca7b3231c4b32cb78a89337.
packages/pinentry/pinentry.el shouldn't directly interact with the secrets 
service,
but ask the caller to cache the passphrase.
---
 packages/pinentry/pinentry.el | 151 +-
 1 file changed, 46 insertions(+), 105 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index aee8647..13a15c9 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -63,11 +63,6 @@
   :type 'integer
   :group 'pinentry)
 
-(defcustom pinentry-use-secrets nil
-  "If non-nil, use secrets.el to store passwords in login keyring."
-  :type 'boolean
-  :group 'pinentry)
-
 (defvar pinentry--server-process nil)
 (defvar pinentry--connection-process-list nil)
 
@@ -75,10 +70,6 @@
 (put 'pinentry-read-point 'permanent-local t)
 (defvar pinentry--read-point nil)
 (put 'pinentry--read-point 'permanent-local t)
-(defvar pinentry--allow-external-password-cache nil)
-(put 'pinentry--allow-external-password-cache 'permanent-local t)
-(defvar pinentry--key-info nil)
-(put 'pinentry--key-info 'permanent-local t)
 
 (defvar pinentry--prompt-buffer nil)
 
@@ -152,10 +143,6 @@ If local sockets are not supported, this is nil.")
(concat prompt (substring short-prompt -2))
query-args)))
 
-(defvar secrets-enabled)
-(declare-function secrets-search-items "secrets" (collection &rest attributes))
-(declare-function secrets-get-secret "secrets" (collection item))
-
 ;;;###autoload
 (defun pinentry-start ()
   "Start a Pinentry service.
@@ -290,23 +277,6 @@ Assuan protocol."
 (defun pinentry--send-error (process error)
   (process-send-string process (format "ERR %d %s\n" (car error) (cdr error
 
-(defun pinentry--send-passphrase (process passphrase)
-  (let (escaped-passphrase encoded-passphrase)
-(unwind-protect
-(condition-case nil
-(progn
-  (setq escaped-passphrase (pinentry--escape-string passphrase))
-  (setq encoded-passphrase (encode-coding-string escaped-passphrase
- 'utf-8))
-  (pinentry--send-data process encoded-passphrase)
-  (process-send-string process "OK\n"))
-  (error
-   (pinentry--send-error process pinentry--error-cancelled)))
-  (if escaped-passphrase
-  (clear-string escaped-passphrase))
-  (if encoded-passphrase
-  (clear-string encoded-passphrase)
-
 (defun pinentry--process-filter (process input)
   (unless (buffer-live-p (process-buffer process))
 (let ((buffer (generate-new-buffer " *pinentry*")))
@@ -316,9 +286,7 @@ Assuan protocol."
 (set-buffer-multibyte nil))
 (make-local-variable 'pinentry--read-point)
 (setq pinentry--read-point (point-min))
-(make-local-variable 'pinentry--labels)
-(make-local-variable 'pinentry--allow-external-password-cache)
-(make-local-variable 'pinentry--key-info
+(make-local-variable 'pinentry--labels
   (with-current-buffer (process-buffer process)
 (save-excursion
   (goto-char (point-max))
@@ -343,79 +311,52 @@ Assuan protocol."
("NOP"
 (ignore-errors
   (process-send-string process "OK\n")))
-("OPTION"
- (if (and pinentry-use-secrets
-  (require 'secrets)
-  secrets-enabled
-  (equal string "allow-external-password-cache"))
- (setq pinentry--allow-external-password-cache t))
- (ignore-errors
-  (process-send-string process "OK\n")))
-("SETKEYINFO"
- (setq pinentry--key-info string)
- (ignore-errors
-  (process-send-string process "OK\n")))
 ("GETPIN"
- (let (passphrase-sent)
-   (when (and pinentry--allow-external-password-cache
-  pinentry--key-info)
- (let ((items
-(secrets-search-items "login"
-  :keygrip 
pinentry--key-info)))
-   (if items
-   (let (passphrase)
- (unwind-protect
- (progn
-   (setq passphrase (secrets-get-secret
- "login"
- (car items)))
-   (ignore-errors
- (process-send-string
-  proc

[elpa] master 952dd9f 07/11: Suppress redundant Pinentry startup messages

2018-01-16 Thread Nicolas Petton
branch: master
commit 952dd9fa4a8e1d6a70aa61fdd84495bb569024d9
Author: Daiki Ueno 
Commit: Nicolas Petton 

Suppress redundant Pinentry startup messages

* packages/pinentry/pinentry.el (pinentry-start): Add optional QUIET
argument.
* lisp/epg.el: Declare `pinentry-start'.
(epg--start): Call `pinentry-start' with QUIET argument set.
---
 packages/pinentry/pinentry.el | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index eaa9fa4..0037006 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -151,16 +151,20 @@ If local sockets are not supported, this is nil.")
   (apply query-function (concat desc "\n" prompt) query-args
 
 ;;;###autoload
-(defun pinentry-start ()
+(defun pinentry-start (&optional quiet)
   "Start a Pinentry service.
 
 Once the environment is properly set, subsequent invocations of
-the gpg command will interact with Emacs for passphrase input."
+the gpg command will interact with Emacs for passphrase input.
+
+If the optional QUIET argument is non-nil, messages at startup
+will not be shown."
   (interactive)
   (unless (featurep 'make-network-process '(:family local))
 (error "local sockets are not supported"))
   (if (process-live-p pinentry--server-process)
-  (message "Pinentry service is already running")
+  (unless quiet
+(message "Pinentry service is already running"))
 (let* ((server-file (expand-file-name "pinentry" pinentry--socket-dir)))
   (server-ensure-safe-dir pinentry--socket-dir)
   ;; Delete the socket files made by previous server invocations.



[elpa] master dcc9ba0 11/11: Set file modes of pinentry socket for extra safety

2018-01-16 Thread Nicolas Petton
branch: master
commit dcc9ba03252ee5d39e03bba31b420e0708c3ba0c
Author: Daiki Ueno 
Commit: Nicolas Petton 

Set file modes of pinentry socket for extra safety

* pinentry.el: Require 'cl-lib for `cl-letf'.
(pinentry-start): Change the file modes of the socket file to 0700.
This is just for extra safety since the parent directory is already
protected with `server-ensure-safe-dir'.
---
 packages/pinentry/pinentry.el | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index d7dca4a..50ea614 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -49,6 +49,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defgroup pinentry nil
   "The Pinentry server"
   :version "25.1"
@@ -172,17 +174,18 @@ will not be shown."
   (ignore-errors
 (let (delete-by-moving-to-trash)
   (delete-file server-file)))
-  (setq pinentry--server-process
-(make-network-process
- :name "pinentry"
- :server t
- :noquery t
- :sentinel #'pinentry--process-sentinel
- :filter #'pinentry--process-filter
- :coding 'no-conversion
- :family 'local
- :service server-file))
-  (process-put pinentry--server-process :server-file server-file
+  (cl-letf (((default-file-modes) ?\700))
+(setq pinentry--server-process
+  (make-network-process
+   :name "pinentry"
+   :server t
+   :noquery t
+   :sentinel #'pinentry--process-sentinel
+   :filter #'pinentry--process-filter
+   :coding 'no-conversion
+   :family 'local
+   :service server-file))
+(process-put pinentry--server-process :server-file server-file)
 
 (defun pinentry-stop ()
   "Stop a Pinentry service."



[elpa] master b2dbb4c 10/11: Revert "Change the default socket location for pinentry"

2018-01-16 Thread Nicolas Petton
branch: master
commit b2dbb4c65dc65af9d2d0320af53fd7f002a9a9d0
Author: Daiki Ueno 
Commit: Nicolas Petton 

Revert "Change the default socket location for pinentry"

This reverts commit e34fbdee8aca84b98393b06b2450837d175999ca.
It turned out that the address is fixed in Pinentry itself.
---
 packages/pinentry/pinentry.el | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index 9e23155..d7dca4a 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -26,9 +26,6 @@
 ;; This package allows GnuPG passphrase to be prompted through the
 ;; minibuffer instead of graphical dialog.
 ;;
-;; This feature requires GnuPG 2.1.5 or later and Pinentry 0.9.5 or
-;; later, with the Emacs support compiled in.
-;;
 ;; To use, add "allow-emacs-pinentry" to "~/.gnupg/gpg-agent.conf",
 ;; reload the configuration with "gpgconf --reload gpg-agent", and
 ;; start the server with M-x pinentry-start.
@@ -41,15 +38,17 @@
 ;; where pinentry and Emacs communicate through a Unix domain socket
 ;; created at:
 ;;
-;;   ~/.emacs.d/pinentry/pinentry
+;;   ${TMPDIR-/tmp}/emacs$(id -u)/pinentry
+;;
+;; under the same directory which server.el uses.  The protocol is a
+;; subset of the Pinentry Assuan protocol described in (info
+;; "(pinentry) Protocol").
 ;;
-;; The protocol is a subset of the Pinentry Assuan protocol described
-;; in (info "(pinentry) Protocol").
+;; NOTE: As of August 2015, this feature requires newer versions of
+;; GnuPG (2.1.5+) and Pinentry (0.9.5+).
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (defgroup pinentry nil
   "The Pinentry server"
   :version "25.1"
@@ -77,7 +76,10 @@
 
 (defvar pinentry--prompt-buffer nil)
 
-(defvar pinentry--socket-dir (locate-user-emacs-file "pinentry")
+;; We use the same location as `server-socket-dir', when local sockets
+;; are supported.
+(defvar pinentry--socket-dir
+  (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))
   "The directory in which to place the server socket.
 If local sockets are not supported, this is nil.")
 
@@ -170,17 +172,16 @@ will not be shown."
   (ignore-errors
 (let (delete-by-moving-to-trash)
   (delete-file server-file)))
-  (cl-letf (((default-file-modes) ?\700))
-(setq pinentry--server-process
-  (make-network-process
-   :name "pinentry"
-   :server t
-   :noquery t
-   :sentinel #'pinentry--process-sentinel
-   :filter #'pinentry--process-filter
-   :coding 'no-conversion
-   :family 'local
-   :service server-file)))
+  (setq pinentry--server-process
+(make-network-process
+ :name "pinentry"
+ :server t
+ :noquery t
+ :sentinel #'pinentry--process-sentinel
+ :filter #'pinentry--process-filter
+ :coding 'no-conversion
+ :family 'local
+ :service server-file))
   (process-put pinentry--server-process :server-file server-file
 
 (defun pinentry-stop ()



[elpa] master 1cfcece 01/11: packages/pinentry/pinentry.el: Popup window for multiline prompt

2018-01-16 Thread Nicolas Petton
branch: master
commit 1cfcece832d095005911c70c52d58b5dcf41ebb9
Author: Daiki Ueno 
Commit: Nicolas Petton 

packages/pinentry/pinentry.el: Popup window for multiline prompt

* packages/pinentry/pinentry.el (pinentry): New custom group.
(pinentry-popup-prompt-window): New user option.
(pinentry-prompt-window-height): New user option.
(pinentry--prompt-buffer): New variable.
(pinentry-prompt-mode-map): New variable.
(pinentry-prompt-mode): New function.
(pinentry--prompt): New function.
(pinentry--process-filter): Use `pinentry--prompt' instead of
`read-passwd' and `y-or-n-p'.
---
 packages/pinentry/pinentry.el | 72 +++
 1 file changed, 66 insertions(+), 6 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index 7cbe9f5..05cb124 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -50,6 +50,21 @@
 
 ;;; Code:
 
+(defgroup pinentry nil
+  "The Pinentry server"
+  :version "25.1"
+  :group 'external)
+
+(defcustom pinentry-popup-prompt-window t
+  "If non-nil, display status information from epa commands in another window."
+  :type 'boolean
+  :group 'pinentry)
+
+(defcustom pinentry-prompt-window-height 5
+  "Number of lines used to display status information."
+  :type 'integer
+  :group 'pinentry)
+
 (defvar pinentry--server-process nil)
 (defvar pinentry--connection-process-list nil)
 
@@ -58,6 +73,8 @@
 (defvar pinentry--read-point nil)
 (put 'pinentry--read-point 'permanent-local t)
 
+(defvar pinentry--prompt-buffer nil)
+
 ;; We use the same location as `server-socket-dir', when local sockets
 ;; are supported.
 (defvar pinentry--socket-dir
@@ -82,6 +99,52 @@ If local sockets are not supported, this is nil.")
 
 (autoload 'server-ensure-safe-dir "server")
 
+(defvar pinentry-prompt-mode-map
+  (let ((keymap (make-sparse-keymap)))
+(define-key keymap "q" 'quit-window)
+keymap))
+
+(define-derived-mode pinentry-prompt-mode special-mode "Pinentry"
+  "Major mode for `pinentry--prompt-buffer'."
+  (buffer-disable-undo)
+  (setq truncate-lines t
+   buffer-read-only t))
+
+(defun pinentry--prompt (prompt short-prompt query-function &rest query-args)
+  (if (and (string-match "\n" prompt)
+   pinentry-popup-prompt-window)
+  (save-window-excursion
+(delete-other-windows)
+   (unless (and pinentry--prompt-buffer
+ (buffer-live-p pinentry--prompt-buffer))
+ (setq pinentry--prompt-buffer (generate-new-buffer "*Pinentry*")))
+   (if (get-buffer-window pinentry--prompt-buffer)
+   (delete-window (get-buffer-window pinentry--prompt-buffer)))
+   (with-current-buffer pinentry--prompt-buffer
+ (let ((inhibit-read-only t)
+   buffer-read-only)
+   (erase-buffer)
+   (insert prompt))
+ (pinentry-prompt-mode)
+ (goto-char (point-min)))
+   (if (> (window-height)
+  pinentry-prompt-window-height)
+   (set-window-buffer (split-window nil
+ (- (window-height)
+pinentry-prompt-window-height))
+  pinentry--prompt-buffer)
+ (pop-to-buffer pinentry--prompt-buffer)
+ (if (> (window-height) pinentry-prompt-window-height)
+ (shrink-window (- (window-height)
+pinentry-prompt-window-height
+(prog1 (apply query-function short-prompt query-args)
+  (quit-window)))
+(apply query-function
+   ;; Append a suffix to the prompt, which can be derived from
+   ;; SHORT-PROMPT.
+   (concat prompt (substring short-prompt -2))
+   query-args)))
+
 ;;;###autoload
 (defun pinentry-start ()
   "Start a Pinentry service.
@@ -267,16 +330,13 @@ Assuan protocol."
(if (setq entry (assq 'title pinentry--labels))
(setq prompt (format "[%s] %s"
 (cdr entry) prompt)))
-   (if (string-match ":?[ \n]*\\'" prompt)
-   (setq prompt (concat
- (substring
-  prompt 0 (match-beginning 0)) ": ")))
(let (passphrase escaped-passphrase encoded-passphrase)
  (unwind-protect
  (condition-case nil
  (progn
(setq passphrase
-(read-passwd prompt confirm))
+(pinentry--prompt prompt "Password: "
+   #'read-passwd confirm))
(setq escaped-passphrase
  (pinentry--escape-string
   passphrase))
@@ -350,7 +4

[elpa] master updated (8d079d3 -> dcc9ba0)

2018-01-16 Thread Nicolas Petton
nicolaspetton pushed a change to branch master.

  from  8d079d3   Do not uncover flagged cells if the user dont want that
   new  1cfcece   packages/pinentry/pinentry.el: Popup window for multiline 
prompt
   new  19227a0   ; pinentry.el: Update header comment and fix typos
   new  adc04d8   pinentry.el: Support external passphrase cache
   new  2a2617f   Revert "pinentry.el: Support external passphrase cache"
   new  7154adf   pinentry.el: Improve multiline prompt
   new  32bec2a   pinentry.el: Add debugging support
   new  952dd9f   Suppress redundant Pinentry startup messages
   new  cd62826   Mention how to enable pinentry feature
   new  efb0175   Change the default socket location for pinentry
   new  b2dbb4c   Revert "Change the default socket location for pinentry"
   new  dcc9ba0   Set file modes of pinentry socket for extra safety


Summary of changes:
 packages/pinentry/pinentry.el | 227 +++---
 1 file changed, 145 insertions(+), 82 deletions(-)



[elpa] master 19227a0 02/11: ; pinentry.el: Update header comment and fix typos

2018-01-16 Thread Nicolas Petton
branch: master
commit 19227a07312b581064ad2f84e1fe501431c47a44
Author: Daiki Ueno 
Commit: Nicolas Petton 

; pinentry.el: Update header comment and fix typos
---
 packages/pinentry/pinentry.el | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/packages/pinentry/pinentry.el b/packages/pinentry/pinentry.el
index 05cb124..13a15c9 100644
--- a/packages/pinentry/pinentry.el
+++ b/packages/pinentry/pinentry.el
@@ -43,10 +43,8 @@
 ;; subset of the Pinentry Assuan protocol described in (info
 ;; "(pinentry) Protocol").
 ;;
-;; NOTE: As of June 2015, this feature requires newer versions of
-;; GnuPG (2.1.5+) and Pinentry (not yet released, possibly 0.9.5+).
-;; For details, see the discussion on gnupg-devel mailing list:
-;; .
+;; NOTE: As of August 2015, this feature requires newer versions of
+;; GnuPG (2.1.5+) and Pinentry (0.9.5+).
 
 ;;; Code:
 
@@ -56,12 +54,12 @@
   :group 'external)
 
 (defcustom pinentry-popup-prompt-window t
-  "If non-nil, display status information from epa commands in another window."
+  "If non-nil, display multiline prompt in another window."
   :type 'boolean
   :group 'pinentry)
 
 (defcustom pinentry-prompt-window-height 5
-  "Number of lines used to display status information."
+  "Number of lines used to display multiline prompt."
   :type 'integer
   :group 'pinentry)