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 /lisp | |
| 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/package.el | 35 |
1 files changed, 26 insertions, 9 deletions
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)))) |