diff options
| author | Daiki Ueno | 2016-02-22 06:06:50 +0900 |
|---|---|---|
| committer | Daiki Ueno | 2016-02-22 06:17:29 +0900 |
| commit | e34fbdee8aca84b98393b06b2450837d175999ca (patch) | |
| tree | e185601c1584540ca75f7f47aec903acee1e9b49 | |
| parent | 5f8965839d573032fc02be1298f37899cf61862d (diff) | |
| download | emacs-e34fbdee8aca84b98393b06b2450837d175999ca.tar.gz emacs-e34fbdee8aca84b98393b06b2450837d175999ca.zip | |
Change the default socket location for pinentry
* lisp/net/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'.
| -rw-r--r-- | lisp/net/pinentry.el | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lisp/net/pinentry.el b/lisp/net/pinentry.el index 285f86481bc..f83b0734fa2 100644 --- a/lisp/net/pinentry.el +++ b/lisp/net/pinentry.el | |||
| @@ -26,6 +26,9 @@ | |||
| 26 | ;; This package allows GnuPG passphrase to be prompted through the | 26 | ;; This package allows GnuPG passphrase to be prompted through the |
| 27 | ;; minibuffer instead of graphical dialog. | 27 | ;; minibuffer instead of graphical dialog. |
| 28 | ;; | 28 | ;; |
| 29 | ;; This feature requires GnuPG 2.1.5 or later and Pinentry 0.9.5 or | ||
| 30 | ;; later, with the Emacs support compiled in. | ||
| 31 | ;; | ||
| 29 | ;; To use, add "allow-emacs-pinentry" to "~/.gnupg/gpg-agent.conf", | 32 | ;; To use, add "allow-emacs-pinentry" to "~/.gnupg/gpg-agent.conf", |
| 30 | ;; reload the configuration with "gpgconf --reload gpg-agent", and | 33 | ;; reload the configuration with "gpgconf --reload gpg-agent", and |
| 31 | ;; start the server with M-x pinentry-start. | 34 | ;; start the server with M-x pinentry-start. |
| @@ -38,17 +41,15 @@ | |||
| 38 | ;; where pinentry and Emacs communicate through a Unix domain socket | 41 | ;; where pinentry and Emacs communicate through a Unix domain socket |
| 39 | ;; created at: | 42 | ;; created at: |
| 40 | ;; | 43 | ;; |
| 41 | ;; ${TMPDIR-/tmp}/emacs$(id -u)/pinentry | 44 | ;; ~/.emacs.d/pinentry/pinentry |
| 42 | ;; | ||
| 43 | ;; under the same directory which server.el uses. The protocol is a | ||
| 44 | ;; subset of the Pinentry Assuan protocol described in (info | ||
| 45 | ;; "(pinentry) Protocol"). | ||
| 46 | ;; | 45 | ;; |
| 47 | ;; NOTE: As of August 2015, this feature requires newer versions of | 46 | ;; The protocol is a subset of the Pinentry Assuan protocol described |
| 48 | ;; GnuPG (2.1.5+) and Pinentry (0.9.5+). | 47 | ;; in (info "(pinentry) Protocol"). |
| 49 | 48 | ||
| 50 | ;;; Code: | 49 | ;;; Code: |
| 51 | 50 | ||
| 51 | (eval-when-compile (require 'cl-lib)) | ||
| 52 | |||
| 52 | (defgroup pinentry nil | 53 | (defgroup pinentry nil |
| 53 | "The Pinentry server" | 54 | "The Pinentry server" |
| 54 | :version "25.1" | 55 | :version "25.1" |
| @@ -76,10 +77,7 @@ | |||
| 76 | 77 | ||
| 77 | (defvar pinentry--prompt-buffer nil) | 78 | (defvar pinentry--prompt-buffer nil) |
| 78 | 79 | ||
| 79 | ;; We use the same location as `server-socket-dir', when local sockets | 80 | (defvar pinentry--socket-dir (locate-user-emacs-file "pinentry") |
| 80 | ;; are supported. | ||
| 81 | (defvar pinentry--socket-dir | ||
| 82 | (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)) | ||
| 83 | "The directory in which to place the server socket. | 81 | "The directory in which to place the server socket. |
| 84 | If local sockets are not supported, this is nil.") | 82 | If local sockets are not supported, this is nil.") |
| 85 | 83 | ||
| @@ -172,16 +170,17 @@ will not be shown." | |||
| 172 | (ignore-errors | 170 | (ignore-errors |
| 173 | (let (delete-by-moving-to-trash) | 171 | (let (delete-by-moving-to-trash) |
| 174 | (delete-file server-file))) | 172 | (delete-file server-file))) |
| 175 | (setq pinentry--server-process | 173 | (cl-letf (((default-file-modes) ?\700)) |
| 176 | (make-network-process | 174 | (setq pinentry--server-process |
| 177 | :name "pinentry" | 175 | (make-network-process |
| 178 | :server t | 176 | :name "pinentry" |
| 179 | :noquery t | 177 | :server t |
| 180 | :sentinel #'pinentry--process-sentinel | 178 | :noquery t |
| 181 | :filter #'pinentry--process-filter | 179 | :sentinel #'pinentry--process-sentinel |
| 182 | :coding 'no-conversion | 180 | :filter #'pinentry--process-filter |
| 183 | :family 'local | 181 | :coding 'no-conversion |
| 184 | :service server-file)) | 182 | :family 'local |
| 183 | :service server-file))) | ||
| 185 | (process-put pinentry--server-process :server-file server-file)))) | 184 | (process-put pinentry--server-process :server-file server-file)))) |
| 186 | 185 | ||
| 187 | (defun pinentry-stop () | 186 | (defun pinentry-stop () |