aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Lechtenboerger2017-04-11 12:27:37 +0300
committerEli Zaretskii2017-04-11 12:27:37 +0300
commit695eacc21ea08b7fa080a232eadae881b5295bef (patch)
tree175dfbbc0bb302b0d2554ade99b0b3cf07090119
parent291b76f91ea991c9fa8e57b55df1b68704931445 (diff)
downloademacs-695eacc21ea08b7fa080a232eadae881b5295bef.tar.gz
emacs-695eacc21ea08b7fa080a232eadae881b5295bef.zip
Introduce customizable variable 'package-gnupghome-dir'
* lisp/emacs-lisp/package.el (package-import-keyring) (package--check-signature-content, package-check-signature): Use new variable package-gnupghome-dir to control which GnuPG homedir to use. * doc/emacs/package.texi: Mention package-gnupghome-dir. * etc/NEWS: Mention package-gnupghome-dir.
-rw-r--r--doc/emacs/package.texi15
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/emacs-lisp/package.el35
3 files changed, 44 insertions, 13 deletions
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index d6f88aaec3c..ecc955d3efe 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -193,15 +193,22 @@ and use only third parties that you think you can trust!
193can have in their packages by @dfn{signing} them. They generate a 193can have in their packages by @dfn{signing} them. They generate a
194private/public pair of cryptographic keys, and use the private key to 194private/public pair of cryptographic keys, and use the private key to
195create a @dfn{signature file} for each package. With the public key, you 195create a @dfn{signature file} for each package. With the public key, you
196can use the signature files to verify who created the package, and 196can use the signature files to verify the package creator and make sure
197that it has not been modified. A valid signature is not a cast-iron 197the package has not been tampered with. Signature verification uses
198@uref{https://www.gnupg.org/, the GnuPG package} via the EasyPG
199interface (@pxref{Top,, EasyPG, epa, Emacs EasyPG Assistant Manual}).
200A valid signature is not a cast-iron
198guarantee that a package is not malicious, so you should still 201guarantee that a package is not malicious, so you should still
199exercise caution. Package archives should provide instructions 202exercise caution. Package archives should provide instructions
200on how you can obtain their public key. One way is to download the 203on how you can obtain their public key. One way is to download the
201key from a server such as @url{http://pgp.mit.edu/}. 204key from a server such as @url{http://pgp.mit.edu/}.
202Use @kbd{M-x package-import-keyring} to import the key into Emacs. 205Use @kbd{M-x package-import-keyring} to import the key into Emacs.
203Emacs stores package keys in the @file{gnupg} subdirectory 206Emacs stores package keys in the directory specified by the variable
204of @code{package-user-dir}. 207@code{package-gnupghome-dir}, by default in the @file{gnupg}
208subdirectory of @code{package-user-dir}, which causes Emacs to invoke
209GnuPG with the option @samp{--homedir} when verifying signatures.
210If @code{package-gnupghome-dir} is @code{nil}, GnuPG's option
211@samp{--homedir} is omitted.
205The public key for the GNU package archive is distributed with Emacs, 212The public key for the GNU package archive is distributed with Emacs,
206in the @file{etc/package-keyring.gpg}. Emacs uses it automatically. 213in the @file{etc/package-keyring.gpg}. Emacs uses it automatically.
207 214
diff --git a/etc/NEWS b/etc/NEWS
index b36db07360b..3c328ac58a2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -644,6 +644,13 @@ In 'visual-line-mode' it will look for the true beginning of a header
644while in non-'visual-line-mode' it will move the point to the indented 644while in non-'visual-line-mode' it will move the point to the indented
645header's value. 645header's value.
646 646
647** Package
648
649+++
650*** The new variable 'package-gnupghome-dir' has been added to control
651where the GnuPG home directory (used for signature verification) is
652located and whether GnuPG's option "--homedir" is used or not.
653
647** Tramp 654** Tramp
648 655
649+++ 656+++
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 769856262b4..bef1e8dd59b 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -307,6 +307,23 @@ contrast, `package-user-dir' contains packages for personal use."
307(declare-function epg-find-configuration "epg-config" 307(declare-function epg-find-configuration "epg-config"
308 (protocol &optional no-cache program-alist)) 308 (protocol &optional no-cache program-alist))
309 309
310(defcustom package-gnupghome-dir (expand-file-name "gnupg" package-user-dir)
311 "Directory containing GnuPG keyring or nil.
312This variable specifies the GnuPG home directory used by package.
313That directory is passed via the option \"--homedir\" to GnuPG.
314If nil, do not use the option \"--homedir\", but stick with GnuPG's
315default directory."
316 :type `(choice
317 (const
318 :tag "Default Emacs package management GnuPG home directory"
319 ,(expand-file-name "gnupg" package-user-dir))
320 (const
321 :tag "Default GnuPG directory (GnuPG option --homedir not used)"
322 nil)
323 (directory :tag "A specific GnuPG --homedir"))
324 :risky t
325 :version "26.1")
326
310(defcustom package-check-signature 327(defcustom package-check-signature
311 (if (and (require 'epg-config) 328 (if (and (require 'epg-config)
312 (epg-find-configuration 'OpenPGP)) 329 (epg-find-configuration 'OpenPGP))
@@ -1209,9 +1226,9 @@ errors signaled by ERROR-FORM or by BODY).
1209 "Check signature CONTENT against STRING. 1226 "Check signature CONTENT against STRING.
1210SIG-FILE is the name of the signature file, used when signaling 1227SIG-FILE is the name of the signature file, used when signaling
1211errors." 1228errors."
1212 (let* ((context (epg-make-context 'OpenPGP)) 1229 (let ((context (epg-make-context 'OpenPGP)))
1213 (homedir (expand-file-name "gnupg" package-user-dir))) 1230 (when package-gnupghome-dir
1214 (setf (epg-context-home-directory context) homedir) 1231 (setf (epg-context-home-directory context) package-gnupghome-dir))
1215 (condition-case error 1232 (condition-case error
1216 (epg-verify-string context content string) 1233 (epg-verify-string context content string)
1217 (error (package--display-verify-error context sig-file) 1234 (error (package--display-verify-error context sig-file)
@@ -1238,7 +1255,7 @@ errors."
1238 "Check signature of the current buffer. 1255 "Check signature of the current buffer.
1239Download the signature file from LOCATION by appending \".sig\" 1256Download the signature file from LOCATION by appending \".sig\"
1240to FILE. 1257to FILE.
1241GnuPG keyring is located under \"gnupg\" in `package-user-dir'. 1258GnuPG keyring location depends on `package-gnupghome-dir'.
1242STRING is the string to verify, it defaults to `buffer-string'. 1259STRING is the string to verify, it defaults to `buffer-string'.
1243If ASYNC is non-nil, the download of the signature file is 1260If ASYNC is non-nil, the download of the signature file is
1244done asynchronously. 1261done asynchronously.
@@ -1478,11 +1495,11 @@ taken care of by `package-initialize'."
1478 "Import keys from FILE." 1495 "Import keys from FILE."
1479 (interactive "fFile: ") 1496 (interactive "fFile: ")
1480 (setq file (expand-file-name file)) 1497 (setq file (expand-file-name file))
1481 (let ((context (epg-make-context 'OpenPGP)) 1498 (let ((context (epg-make-context 'OpenPGP)))
1482 (homedir (expand-file-name "gnupg" package-user-dir))) 1499 (when package-gnupghome-dir
1483 (with-file-modes 448 1500 (with-file-modes 448
1484 (make-directory homedir t)) 1501 (make-directory package-gnupghome-dir t))
1485 (setf (epg-context-home-directory context) homedir) 1502 (setf (epg-context-home-directory context) package-gnupghome-dir))
1486 (message "Importing %s..." (file-name-nondirectory file)) 1503 (message "Importing %s..." (file-name-nondirectory file))
1487 (epg-import-keys-from-file context file) 1504 (epg-import-keys-from-file context file)
1488 (message "Importing %s...done" (file-name-nondirectory file)))) 1505 (message "Importing %s...done" (file-name-nondirectory file))))