nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0104-New-command-list_trusted.patch

f96e0b
From 232b501f28ef5a2b6c67a73a4b3babe8a3457330 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Sun, 13 Jan 2013 17:49:05 +0100
f96e0b
Subject: [PATCH 104/482] 	New command list_trusted.
f96e0b
f96e0b
	* grub-core/commands/verify.c (grub_cmd_list): New function.
f96e0b
---
f96e0b
 ChangeLog                   |  6 ++++++
f96e0b
 grub-core/commands/verify.c | 31 ++++++++++++++++++++++++++-----
f96e0b
 2 files changed, 32 insertions(+), 5 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 784d737..6bb855b 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,9 @@
f96e0b
+2013-01-13  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
+	New command list_trusted.
f96e0b
+
f96e0b
+	* grub-core/commands/verify.c (grub_cmd_list): New function.
f96e0b
+
f96e0b
 2013-01-13  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
 
f96e0b
 	* util/grub-mkimage.c (generate_image): Fix "size of public key"
f96e0b
diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c
f96e0b
index 66a027f..d399d0f 100644
f96e0b
--- a/grub-core/commands/verify.c
f96e0b
+++ b/grub-core/commands/verify.c
f96e0b
@@ -298,10 +298,6 @@ grub_load_public_key (grub_file_t f)
f96e0b
       *last = sk;
f96e0b
       last = &sk->next;
f96e0b
 
f96e0b
-      for (i = 0; i < 20; i += 2)
f96e0b
-	grub_printf ("%02x%02x ", ((grub_uint8_t *) sk->fingerprint)[i], ((grub_uint8_t *) sk->fingerprint)[i + 1]);
f96e0b
-      grub_printf ("\n");
f96e0b
-
f96e0b
       grub_dprintf ("crypt", "actual pos: %x, expected: %x\n", (int)grub_file_tell (f), (int)pend);
f96e0b
 
f96e0b
       grub_file_seek (f, pend);
f96e0b
@@ -557,6 +553,27 @@ grub_cmd_trust (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
 }
f96e0b
 
f96e0b
 static grub_err_t
f96e0b
+grub_cmd_list (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
+	       int argc __attribute__ ((unused)),
f96e0b
+	       char **args __attribute__ ((unused)))
f96e0b
+{
f96e0b
+  struct grub_public_key *pk = NULL;
f96e0b
+  struct grub_public_subkey *sk = NULL;
f96e0b
+
f96e0b
+  for (pk = grub_pk_trusted; pk; pk = pk->next)
f96e0b
+    for (sk = pk->subkeys; sk; sk = sk->next)
f96e0b
+      {
f96e0b
+	unsigned i;
f96e0b
+	for (i = 0; i < 20; i += 2)
f96e0b
+	  grub_printf ("%02x%02x ", ((grub_uint8_t *) sk->fingerprint)[i],
f96e0b
+		       ((grub_uint8_t *) sk->fingerprint)[i + 1]);
f96e0b
+	grub_printf ("\n");
f96e0b
+      }
f96e0b
+
f96e0b
+  return GRUB_ERR_NONE;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
 grub_cmd_distrust (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
 		   int argc, char **args)
f96e0b
 {
f96e0b
@@ -701,7 +718,7 @@ struct gcry_pk_spec *grub_crypto_pk_dsa;
f96e0b
 struct gcry_pk_spec *grub_crypto_pk_ecdsa;
f96e0b
 struct gcry_pk_spec *grub_crypto_pk_rsa;
f96e0b
 
f96e0b
-static grub_command_t cmd, cmd_trust, cmd_distrust;
f96e0b
+static grub_command_t cmd, cmd_trust, cmd_distrust, cmd_list;
f96e0b
 
f96e0b
 GRUB_MOD_INIT(verify)
f96e0b
 {
f96e0b
@@ -752,6 +769,9 @@ GRUB_MOD_INIT(verify)
f96e0b
   cmd_trust = grub_register_command ("trust", grub_cmd_trust,
f96e0b
 				     N_("PUBKEY_FILE"),
f96e0b
 				     N_("Add PKFILE to trusted keys."));
f96e0b
+  cmd_list = grub_register_command ("list_trusted", grub_cmd_list,
f96e0b
+				    0,
f96e0b
+				    N_("List trusted keys."));
f96e0b
   cmd_distrust = grub_register_command ("distrust", grub_cmd_distrust,
f96e0b
 					N_("PUBKEY_ID"),
f96e0b
 					N_("Remove KEYID from trusted keys."));
f96e0b
@@ -762,5 +782,6 @@ GRUB_MOD_FINI(verify)
f96e0b
   grub_file_filter_unregister (GRUB_FILE_FILTER_PUBKEY);
f96e0b
   grub_unregister_command (cmd);
f96e0b
   grub_unregister_command (cmd_trust);
f96e0b
+  grub_unregister_command (cmd_list);
f96e0b
   grub_unregister_command (cmd_distrust);
f96e0b
 }
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b