GNU bug report logs - #19960
epg: allow passing --keyring values via new epg-context-keyrings

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Fri, 27 Feb 2015 16:14:02 UTC

Severity: wishlist

Tags: patch, wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ivan Shmakov <ivan <at> siamics.net>
To: 19960 <at> debbugs.gnu.org
Subject: bug#19960: epg: allow passing --keyring values via new epg-context-keyrings 
Date: Fri, 27 Feb 2015 16:12:49 +0000
[Message part 1 (text/plain, inline)]
Package:  emacs
Severity: wishlist
Tags: patch

	Please consider the patch MIMEd.

	* lisp/epg.el (epg-context): New slot: keyrings.
	(epg--start): Use it.
	(epg--list-keys-1): Likewise.  (Bug#???)

	An example code making use of this change (assuming that the
	extra keyring is available at the location usual to Debian
	Jessie) is also MIMEd.

	(Tested on 619fc5c197eb, 2015-02-26 18:09:48 UTC.)

-- 
FSF associate member #7257  np. Gates of Tomorrow — Iron Maiden   … 230E 334A
[Message part 2 (text/diff, inline)]
diff --git a/lisp/epg.el b/lisp/epg.el
index f665453..0768697 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -197,6 +197,7 @@ cl-defstruct epg-context
   protocol
   program
   (home-directory epg-gpg-home-directory)
+  keyrings
   armor
   textmode
   include-certs
@@ -570,6 +571,11 @@ defun epg--start (context args)
 		       (if (epg-context-home-directory context)
 			   (list "--homedir"
 				 (epg-context-home-directory context)))
+		       (if (epg-context-keyrings context)
+			   (apply #'nconc
+				  (mapcar (lambda (elt)
+					    (list "--keyring" elt))
+					  (epg-context-keyrings context))))
 		       (unless (eq (epg-context-protocol context) 'CMS)
 			 '("--command-fd" "0"))
 		       (if (epg-context-armor context) '("--armor"))
@@ -1263,6 +1269,11 @@ defun epg--list-keys-1 (context name mode)
   (let ((args (append (if (epg-context-home-directory context)
 			  (list "--homedir"
 				(epg-context-home-directory context)))
+		       (if (epg-context-keyrings context)
+			   (apply #'nconc
+				  (mapcar (lambda (elt)
+					    (list "--keyring" elt))
+					  (epg-context-keyrings context))))
 		      '("--with-colons" "--no-greeting" "--batch"
 			"--with-fingerprint" "--with-fingerprint")
 		      (unless (eq (epg-context-protocol context) 'CMS)
[Message part 3 (text/emacs-lisp, inline)]
(let ((cx (epg-make-context 'OpenPGP))
      (s  (with-current-buffer
              (url-retrieve-synchronously
               "http://snapshot.debian.org/archive/debian/20140501T070413Z/dists/jessie/InRelease")
            (buffer-substring-no-properties
             url-http-end-of-headers (point-max))))
      a b)
  (setq a (progn
            (epg-verify-string cx s)
            (epg-context-result-for cx 'verify)))
  (push "/etc/apt/trusted.gpg.d/debian-archive-wheezy-automatic.gpg"
        (epg-context-keyrings cx))
  (setq b (progn
            (epg-verify-string cx s)
            (epg-context-result-for cx 'verify)))
  ;; .
  (list a b))
;; Expected result:
; (([cl-struct-epg-signature
;    no-pubkey "8B48AD6246925553" nil nil
;    (21345 . 47158) nil 1 8 1 nil nil])
;  ([cl-struct-epg-signature
;    good "8B48AD6246925553" undefined
;    "A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553"
;    (21345 . 47158) nil 1 8 1 4 nil]))

This bug report was last modified 9 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.