diff --git a/src/app/main.c b/src/app/main.c index a093b522..9ee2d6e2 100644 --- a/src/app/main.c +++ b/src/app/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/app/rpmostree-builtin-upgrade.c b/src/app/rpmostree-builtin-upgrade.c index e67f9f07..432eac8a 100644 --- a/src/app/rpmostree-builtin-upgrade.c +++ b/src/app/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/app/rpmostree-builtins.h b/src/app/rpmostree-builtins.h index 8e1c5d12..480d06c6 100644 --- a/src/app/rpmostree-builtins.h +++ b/src/app/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