diff options
| author | Jens Lechtenboerger | 2017-04-11 12:27:37 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-04-11 12:27:37 +0300 |
| commit | 695eacc21ea08b7fa080a232eadae881b5295bef (patch) | |
| tree | 175dfbbc0bb302b0d2554ade99b0b3cf07090119 | |
| parent | 291b76f91ea991c9fa8e57b55df1b68704931445 (diff) | |
| download | emacs-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.texi | 15 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 35 |
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! | |||
| 193 | can have in their packages by @dfn{signing} them. They generate a | 193 | can have in their packages by @dfn{signing} them. They generate a |
| 194 | private/public pair of cryptographic keys, and use the private key to | 194 | private/public pair of cryptographic keys, and use the private key to |
| 195 | create a @dfn{signature file} for each package. With the public key, you | 195 | create a @dfn{signature file} for each package. With the public key, you |
| 196 | can use the signature files to verify who created the package, and | 196 | can use the signature files to verify the package creator and make sure |
| 197 | that it has not been modified. A valid signature is not a cast-iron | 197 | the package has not been tampered with. Signature verification uses |
| 198 | @uref{https://www.gnupg.org/, the GnuPG package} via the EasyPG | ||
| 199 | interface (@pxref{Top,, EasyPG, epa, Emacs EasyPG Assistant Manual}). | ||
| 200 | A valid signature is not a cast-iron | ||
| 198 | guarantee that a package is not malicious, so you should still | 201 | guarantee that a package is not malicious, so you should still |
| 199 | exercise caution. Package archives should provide instructions | 202 | exercise caution. Package archives should provide instructions |
| 200 | on how you can obtain their public key. One way is to download the | 203 | on how you can obtain their public key. One way is to download the |
| 201 | key from a server such as @url{http://pgp.mit.edu/}. | 204 | key from a server such as @url{http://pgp.mit.edu/}. |
| 202 | Use @kbd{M-x package-import-keyring} to import the key into Emacs. | 205 | Use @kbd{M-x package-import-keyring} to import the key into Emacs. |
| 203 | Emacs stores package keys in the @file{gnupg} subdirectory | 206 | Emacs stores package keys in the directory specified by the variable |
| 204 | of @code{package-user-dir}. | 207 | @code{package-gnupghome-dir}, by default in the @file{gnupg} |
| 208 | subdirectory of @code{package-user-dir}, which causes Emacs to invoke | ||
| 209 | GnuPG with the option @samp{--homedir} when verifying signatures. | ||
| 210 | If @code{package-gnupghome-dir} is @code{nil}, GnuPG's option | ||
| 211 | @samp{--homedir} is omitted. | ||
| 205 | The public key for the GNU package archive is distributed with Emacs, | 212 | The public key for the GNU package archive is distributed with Emacs, |
| 206 | in the @file{etc/package-keyring.gpg}. Emacs uses it automatically. | 213 | in the @file{etc/package-keyring.gpg}. Emacs uses it automatically. |
| 207 | 214 | ||
| @@ -644,6 +644,13 @@ In 'visual-line-mode' it will look for the true beginning of a header | |||
| 644 | while in non-'visual-line-mode' it will move the point to the indented | 644 | while in non-'visual-line-mode' it will move the point to the indented |
| 645 | header's value. | 645 | header's value. |
| 646 | 646 | ||
| 647 | ** Package | ||
| 648 | |||
| 649 | +++ | ||
| 650 | *** The new variable 'package-gnupghome-dir' has been added to control | ||
| 651 | where the GnuPG home directory (used for signature verification) is | ||
| 652 | located 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. | ||
| 312 | This variable specifies the GnuPG home directory used by package. | ||
| 313 | That directory is passed via the option \"--homedir\" to GnuPG. | ||
| 314 | If nil, do not use the option \"--homedir\", but stick with GnuPG's | ||
| 315 | default 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. |
| 1210 | SIG-FILE is the name of the signature file, used when signaling | 1227 | SIG-FILE is the name of the signature file, used when signaling |
| 1211 | errors." | 1228 | errors." |
| 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. |
| 1239 | Download the signature file from LOCATION by appending \".sig\" | 1256 | Download the signature file from LOCATION by appending \".sig\" |
| 1240 | to FILE. | 1257 | to FILE. |
| 1241 | GnuPG keyring is located under \"gnupg\" in `package-user-dir'. | 1258 | GnuPG keyring location depends on `package-gnupghome-dir'. |
| 1242 | STRING is the string to verify, it defaults to `buffer-string'. | 1259 | STRING is the string to verify, it defaults to `buffer-string'. |
| 1243 | If ASYNC is non-nil, the download of the signature file is | 1260 | If ASYNC is non-nil, the download of the signature file is |
| 1244 | done asynchronously. | 1261 | done 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)))) |