Skip to content

Commit

Permalink
Suppress debug output when completing
Browse files Browse the repository at this point in the history
Any log output interferes with comletion.
We already refrain from installing our verbose
log handlers in this case, but we are still
vulnerable to GLib default message handling,
e.g. via the G_MESSAGES_DEBUG environment
variable. To avoid that, explicitly install
a message handler that suppresses all output.

Closes: flatpak/flatpak#2860

Closes: #2862
Approved by: alexlarsson
  • Loading branch information
Matthias Clasen authored and rh-atomic-bot committed Apr 29, 2019
1 parent c3df39a commit 5020790
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/flatpak-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ message_handler (const gchar *log_domain,
g_printerr ("F: %s\n", message);
}

static void
no_message_handler (const char *log_domain,
GLogLevelFlags log_level,
const char *message,
gpointer user_data)
{
}

static GOptionContext *
flatpak_option_context_new_with_commands (FlatpakCommand *commands)
{
Expand Down Expand Up @@ -320,7 +328,11 @@ flatpak_option_context_parse (GOptionContext *context,
return FALSE;

/* We never want verbose output in the complete case, that breaks completion */
if (!is_in_complete)
if (is_in_complete)
{
g_log_set_default_handler (no_message_handler, NULL);
}
else
{
if (opt_verbose > 0)
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL);
Expand Down

0 comments on commit 5020790

Please sign in to comment.