Blame SOURCES/0001-upgrade-Print-any-GPG-signatures-while-upgrading.patch

f13179
From 750a8889f08c4d3ed90f185cf4a0df379271f2bb Mon Sep 17 00:00:00 2001
f13179
From: Matthew Barnes <mbarnes@redhat.com>
f13179
Date: Mon, 6 Apr 2015 13:09:37 -0400
f13179
Subject: [PATCH 1/2] upgrade: Print any GPG signatures while upgrading
f13179
f13179
---
f13179
 main.c                      | 25 +++++++++++++++++++++++++
f13179
 rpmostree-builtin-upgrade.c | 22 ++++++++++++++++++++++
f13179
 rpmostree-builtins.h        |  2 ++
f13179
 3 files changed, 49 insertions(+)
f13179
f13179
diff --git a/src/app/main.c b/src/app/main.c
f13179
index a093b52..9ee2d6e 100644
f13179
--- a/src/main.c
f13179
+++ b/src/main.c
f13179
@@ -99,6 +99,31 @@ rpmostree_option_context_parse (GOptionContext *context,
f13179
   return TRUE;
f13179
 }
f13179
 
f13179
+void
f13179
+rpmostree_print_gpg_verify_result (OstreeGpgVerifyResult *result)
f13179
+{
f13179
+  GString *buffer;
f13179
+  guint n_sigs, ii;
f13179
+
f13179
+  n_sigs = ostree_gpg_verify_result_count_all (result);
f13179
+
f13179
+  /* XXX If we ever add internationalization, use ngettext() here. */
f13179
+  g_print ("GPG: Verification enabled, found %u signature%s:\n",
f13179
+           n_sigs, n_sigs == 1 ? "" : "s");
f13179
+
f13179
+  buffer = g_string_sized_new (256);
f13179
+
f13179
+  for (ii = 0; ii < n_sigs; ii++)
f13179
+    {
f13179
+      g_string_append_c (buffer, '\n');
f13179
+      ostree_gpg_verify_result_describe (result, ii, buffer, "  ",
f13179
+                                         OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
f13179
+    }
f13179
+
f13179
+  g_print ("%s\n", buffer->str);
f13179
+  g_string_free (buffer, TRUE);
f13179
+}
f13179
+
f13179
 int
f13179
 main (int    argc,
f13179
       char **argv)
f13179
diff --git a/src/rpmostree-builtin-upgrade.c b/src/rpmostree-builtin-upgrade.c
f13179
index e67f9f0..432eac8 100644
f13179
--- a/src/rpmostree-builtin-upgrade.c
f13179
+++ b/src/rpmostree-builtin-upgrade.c
f13179
@@ -45,6 +45,20 @@ static GOptionEntry option_entries[] = {
f13179
   { NULL }
f13179
 };
f13179
 
f13179
+static void
f13179
+gpg_verify_result_cb (OstreeRepo *repo,
f13179
+                      const char *checksum,
f13179
+                      OstreeGpgVerifyResult *result,
f13179
+                      GSConsole *console)
f13179
+{
f13179
+  /* Temporarily place the GSConsole stream (which is just stdout)
f13179
+   * back in normal mode before printing GPG verification results. */
f13179
+  gs_console_end_status_line (console, NULL, NULL);
f13179
+
f13179
+  g_print ("\n");
f13179
+  rpmostree_print_gpg_verify_result (result);
f13179
+}
f13179
+
f13179
 gboolean
f13179
 rpmostree_builtin_upgrade (int             argc,
f13179
                            char          **argv,
f13179
@@ -63,6 +77,7 @@ rpmostree_builtin_upgrade (int             argc,
f13179
 
f13179
   gs_free char *origin_description = NULL;
f13179
   gs_unref_object OstreeRepo *repo = NULL; 
f13179
+  gulong signal_handler_id = 0;
f13179
 
f13179
   if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, error))
f13179
     goto out;
f13179
@@ -89,6 +104,10 @@ rpmostree_builtin_upgrade (int             argc,
f13179
     {
f13179
       gs_console_begin_status_line (console, "", NULL, NULL);
f13179
       progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, console);
f13179
+      signal_handler_id = g_signal_connect (repo, "gpg-verify-result",
f13179
+                                            G_CALLBACK (gpg_verify_result_cb),
f13179
+                                            console);
f13179
+
f13179
     }
f13179
 
f13179
   if (opt_allow_downgrade)  
f13179
@@ -185,5 +204,8 @@ rpmostree_builtin_upgrade (int             argc,
f13179
   if (console)
f13179
     (void) gs_console_end_status_line (console, NULL, NULL);
f13179
 
f13179
+  if (signal_handler_id > 0)
f13179
+    g_signal_handler_disconnect (repo, signal_handler_id);
f13179
+
f13179
   return ret;
f13179
 }
f13179
diff --git a/src/rpmostree-builtins.h b/src/rpmostree-builtins.h
f13179
index 8e1c5d1..480d06c 100644
f13179
--- a/src/rpmostree-builtins.h
f13179
+++ b/src/rpmostree-builtins.h
f13179
@@ -46,5 +46,7 @@ gboolean rpmostree_option_context_parse (GOptionContext *context,
f13179
                                          char ***argv,
f13179
                                          GError **error);
f13179
 
f13179
+void rpmostree_print_gpg_verify_result (OstreeGpgVerifyResult *result);
f13179
+
f13179
 G_END_DECLS
f13179
 
f13179
-- 
f13179
1.8.3.1
f13179