From cff3a1c08d6773410221717015cf9e051c4c7fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 5 Mar 2021 02:33:59 +0000 Subject: [PATCH] prefs: Don't clobber env variable G_MESSAGES_DEBUG Avoid silently overwriting the user's configuration. Ping #17271. --- epan/prefs.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/epan/prefs.c b/epan/prefs.c index 6379db9fd5..0e37eedb33 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -2445,11 +2445,20 @@ console_log_level_set_cb(pref_t* pref, const gchar* value, unsigned int* changed } if (*pref->varp.uint & (G_LOG_LEVEL_INFO|G_LOG_LEVEL_DEBUG)) { - /* - * GLib >= 2.32 drops INFO and DEBUG messages by default. Tell - * it not to do that. - */ - g_setenv("G_MESSAGES_DEBUG", "all", TRUE); + /* + * GLib drops INFO and DEBUG messages by default. If the user + * hasn't set G_MESSAGES_DEBUG, possibly to a specific set of + * domains, tell it not to do that. + */ + const char *s = g_getenv("G_MESSAGES_DEBUG"); + if(s != NULL) { + g_message("prefs: Skip overwriting environment variable " + "G_MESSAGES_DEBUG=\"%s\"", s); + } + else { + g_info("prefs: Set environment variable G_MESSAGES_DEBUG=\"all\""); + g_setenv("G_MESSAGES_DEBUG", "all", FALSE); + } } return PREFS_SET_OK;