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