emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r118303: package.el: Display output sent to stderr,


From: Daiki Ueno
Subject: [Emacs-diffs] trunk r118303: package.el: Display output sent to stderr, when verification failed
Date: Thu, 06 Nov 2014 03:45:32 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 118303
revision-id: address@hidden
parent: address@hidden
committer: Daiki Ueno <address@hidden>
branch nick: trunk
timestamp: Thu 2014-11-06 12:44:52 +0900
message:
  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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/package.el     package.el-20100617020707-ybavz666awsxwin6-2
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-11-06 03:27:23 +0000
+++ b/lisp/ChangeLog    2014-11-06 03:44:52 +0000
@@ -1,3 +1,8 @@
+2014-11-06  Daiki Ueno  <address@hidden>
+
+       * emacs-lisp/package.el (package--display-verify-error): New function.
+       (package--check-signature): Use it to display output sent to stderr.
+
 2014-11-06  Stefan Monnier  <address@hidden>
 
        * subr.el (pop): Don't call the getter twice (bug#18968).

=== modified file 'lisp/emacs-lisp/package.el'
--- a/lisp/emacs-lisp/package.el        2014-10-24 23:02:25 +0000
+++ b/lisp/emacs-lisp/package.el        2014-11-06 03:44:52 +0000
@@ -812,6 +812,18 @@
 (declare-function epg-signature-status "epg" (signature))
 (declare-function epg-signature-to-string "epg" (signature))
 
+(defun package--display-verify-error (context sig-file)
+  (unless (equal (epg-context-error-output context) "")
+    (with-output-to-temp-buffer "*Error*"
+      (with-current-buffer standard-output
+       (if (epg-context-result-for context 'verify)
+           (insert (format "Failed to verify signature %s:\n" sig-file)
+                   (mapconcat #'epg-signature-to-string
+                              (epg-context-result-for context 'verify)
+                              "\n"))
+         (insert (format "Error while verifying signature %s:\n" sig-file)))
+       (insert "\nCommand output:\n" (epg-context-error-output context))))))
+
 (defun package--check-signature (location file)
   "Check signature of the current buffer.
 GnuPG keyring is located under \"gnupg\" in `package-user-dir'."
@@ -821,7 +833,11 @@
          (sig-content (package--with-work-buffer location sig-file
                        (buffer-string))))
     (setf (epg-context-home-directory context) homedir)
-    (epg-verify-string context sig-content (buffer-string))
+    (condition-case error
+       (epg-verify-string context sig-content (buffer-string))
+      (error
+       (package--display-verify-error context sig-file)
+       (signal (car error) (cdr error))))
     (let (good-signatures had-fatal-error)
       ;; The .sig file may contain multiple signatures.  Success if one
       ;; of the signatures is good.
@@ -835,12 +851,12 @@
          (unless (and (eq package-check-signature 'allow-unsigned)
                       (eq (epg-signature-status sig) 'no-pubkey))
            (setq had-fatal-error t))))
-      (if (and (null good-signatures) had-fatal-error)
-          (error "Failed to verify signature %s: %S"
-                 sig-file
-                 (mapcar #'epg-signature-to-string
-                         (epg-context-result-for context 'verify)))
-        good-signatures))))
+      (when (and (null good-signatures) had-fatal-error)
+       (package--display-verify-error context sig-file)
+       (error "Failed to verify signature %s: %S"
+              sig-file
+              ))
+      good-signatures)))
 
 (defun package-install-from-archive (pkg-desc)
   "Download and install a tar package."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]