From 11303fd2d1a0b398bf5c92c620f6d798a610f0dd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 21 Jun 2018 08:04:33 +0200 Subject: [PATCH] main: accept invalid logging configuration in NetworkManager.conf gracefully https://bugzilla.redhat.com/show_bug.cgi?id=1593519 --- src/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 5cb7e785bf..544f0ac1d2 100644 --- a/src/main.c +++ b/src/main.c @@ -232,6 +232,7 @@ main (int argc, char *argv[]) char *bad_domains = NULL; NMConfigCmdLineOptions *config_cli; guint sd_id = 0; + GError *error_invalid_logging_config = NULL; /* Known to cause a possible deadlock upon GDBus initialization: * https://bugzilla.gnome.org/show_bug.cgi?id=674885 */ @@ -330,10 +331,8 @@ main (int argc, char *argv[]) if (!nm_logging_setup (nm_config_get_log_level (config), nm_config_get_log_domains (config), &bad_domains, - &error)) { - fprintf (stderr, _("Error in configuration file: %s.\n"), - error->message); - exit (1); + &error_invalid_logging_config)) { + /* ignore error, and print the failure reason below. */ } else if (bad_domains) { fprintf (stderr, _("Ignoring unrecognized log domain(s) '%s' from config files.\n"), @@ -374,6 +373,11 @@ main (int argc, char *argv[]) nm_log_info (LOGD_CORE, "Read config: %s", nm_config_data_get_config_description (nm_config_get_data (config))); nm_config_data_log (nm_config_get_data (config), "CONFIG: ", " ", NULL); + if (error_invalid_logging_config) { + nm_log_warn (LOGD_CORE, "config: invalid logging configuration: %s", error_invalid_logging_config->message); + g_clear_error (&error_invalid_logging_config); + } + /* the first access to State causes the file to be read (and possibly print a warning) */ nm_config_state_get (config);