diff options
| author | Daiki Ueno | 2014-11-06 12:44:52 +0900 |
|---|---|---|
| committer | Daiki Ueno | 2014-11-06 12:44:52 +0900 |
| commit | 4cd90e0920fd2c7c112d3a098c822934fef444aa (patch) | |
| tree | 81b9265207324f73d476e0729dab2eecfc9e9e4c | |
| parent | f374845f4c52598e6af79dcc32f02356da796074 (diff) | |
| download | emacs-4cd90e0920fd2c7c112d3a098c822934fef444aa.tar.gz emacs-4cd90e0920fd2c7c112d3a098c822934fef444aa.zip | |
package.el: Display output sent to stderr, when verification failed
* emacs-lisp/package.el (package--display-verify-error): New function.
(package--check-signature): Use it to display output sent to stderr.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 30 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7dc4786aff5..1e447d446db 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-11-06 Daiki Ueno <ueno@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/package.el (package--display-verify-error): New function. | ||
| 4 | (package--check-signature): Use it to display output sent to stderr. | ||
| 5 | |||
| 1 | 2014-11-06 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2014-11-06 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * subr.el (pop): Don't call the getter twice (bug#18968). | 8 | * subr.el (pop): Don't call the getter twice (bug#18968). |
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index e375a1e2301..436cd1940a9 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -812,6 +812,18 @@ buffer is killed afterwards. Return the last value in BODY." | |||
| 812 | (declare-function epg-signature-status "epg" (signature)) | 812 | (declare-function epg-signature-status "epg" (signature)) |
| 813 | (declare-function epg-signature-to-string "epg" (signature)) | 813 | (declare-function epg-signature-to-string "epg" (signature)) |
| 814 | 814 | ||
| 815 | (defun package--display-verify-error (context sig-file) | ||
| 816 | (unless (equal (epg-context-error-output context) "") | ||
| 817 | (with-output-to-temp-buffer "*Error*" | ||
| 818 | (with-current-buffer standard-output | ||
| 819 | (if (epg-context-result-for context 'verify) | ||
| 820 | (insert (format "Failed to verify signature %s:\n" sig-file) | ||
| 821 | (mapconcat #'epg-signature-to-string | ||
| 822 | (epg-context-result-for context 'verify) | ||
| 823 | "\n")) | ||
| 824 | (insert (format "Error while verifying signature %s:\n" sig-file))) | ||
| 825 | (insert "\nCommand output:\n" (epg-context-error-output context)))))) | ||
| 826 | |||
| 815 | (defun package--check-signature (location file) | 827 | (defun package--check-signature (location file) |
| 816 | "Check signature of the current buffer. | 828 | "Check signature of the current buffer. |
| 817 | GnuPG keyring is located under \"gnupg\" in `package-user-dir'." | 829 | GnuPG keyring is located under \"gnupg\" in `package-user-dir'." |
| @@ -821,7 +833,11 @@ GnuPG keyring is located under \"gnupg\" in `package-user-dir'." | |||
| 821 | (sig-content (package--with-work-buffer location sig-file | 833 | (sig-content (package--with-work-buffer location sig-file |
| 822 | (buffer-string)))) | 834 | (buffer-string)))) |
| 823 | (setf (epg-context-home-directory context) homedir) | 835 | (setf (epg-context-home-directory context) homedir) |
| 824 | (epg-verify-string context sig-content (buffer-string)) | 836 | (condition-case error |
| 837 | (epg-verify-string context sig-content (buffer-string)) | ||
| 838 | (error | ||
| 839 | (package--display-verify-error context sig-file) | ||
| 840 | (signal (car error) (cdr error)))) | ||
| 825 | (let (good-signatures had-fatal-error) | 841 | (let (good-signatures had-fatal-error) |
| 826 | ;; The .sig file may contain multiple signatures. Success if one | 842 | ;; The .sig file may contain multiple signatures. Success if one |
| 827 | ;; of the signatures is good. | 843 | ;; of the signatures is good. |
| @@ -835,12 +851,12 @@ GnuPG keyring is located under \"gnupg\" in `package-user-dir'." | |||
| 835 | (unless (and (eq package-check-signature 'allow-unsigned) | 851 | (unless (and (eq package-check-signature 'allow-unsigned) |
| 836 | (eq (epg-signature-status sig) 'no-pubkey)) | 852 | (eq (epg-signature-status sig) 'no-pubkey)) |
| 837 | (setq had-fatal-error t)))) | 853 | (setq had-fatal-error t)))) |
| 838 | (if (and (null good-signatures) had-fatal-error) | 854 | (when (and (null good-signatures) had-fatal-error) |
| 839 | (error "Failed to verify signature %s: %S" | 855 | (package--display-verify-error context sig-file) |
| 840 | sig-file | 856 | (error "Failed to verify signature %s: %S" |
| 841 | (mapcar #'epg-signature-to-string | 857 | sig-file |
| 842 | (epg-context-result-for context 'verify))) | 858 | )) |
| 843 | good-signatures)))) | 859 | good-signatures))) |
| 844 | 860 | ||
| 845 | (defun package-install-from-archive (pkg-desc) | 861 | (defun package-install-from-archive (pkg-desc) |
| 846 | "Download and install a tar package." | 862 | "Download and install a tar package." |