From 24f15fa32110b5aedbb605a5d73ab85f4b426e69 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 27 Oct 2011 10:28:53 +0200 Subject: [PATCH] Don't warn about non enable non existing output module This patch modifies output module loading to only trigger alert message for non existing modules when they are loaded. It also warn about unified1 removal. --- src/runmodes.c | 67 +++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/runmodes.c b/src/runmodes.c index ad814766b8..f13abfa64b 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -334,14 +334,7 @@ void RunModeInitializeOutputs(void) if (strcmp(output->val, "stats") == 0) continue; - OutputModule *module = OutputGetModuleByConfName(output->val); - if (module == NULL) { - SCLogWarning(SC_ERR_INVALID_ARGUMENT, - "No output module named %s, ignoring", output->val); - continue; - } - - output_config = ConfNodeLookupChild(output, module->conf_name); + output_config = ConfNodeLookupChild(output, output->val); if (output_config == NULL) { /* Shouldn't happen. */ SCLogError(SC_ERR_INVALID_ARGUMENT, @@ -350,29 +343,47 @@ void RunModeInitializeOutputs(void) } enabled = ConfNodeLookupChildValue(output_config, "enabled"); - if (enabled != NULL && ConfValIsTrue(enabled)) { - OutputCtx *output_ctx = NULL; - if (module->InitFunc != NULL) { - output_ctx = module->InitFunc(output_config); - if (output_ctx == NULL) { - /* In most cases the init function will have logged the - * error. Maybe we should exit on init errors? */ - continue; - } + if (enabled == NULL || !ConfValIsTrue(enabled)) { + continue; + } + + if (strncmp(output->val, "unified-", sizeof("unified-") - 1) == 0) { + SCLogWarning(SC_ERR_INVALID_ARGUMENT, + "Unified1 is no longer supported," + " use Unified2 instead " + "(see https://redmine.openinfosecfoundation.org/issues/353" + " for an explanation)"); + continue; + } + + OutputModule *module = OutputGetModuleByConfName(output->val); + if (module == NULL) { + SCLogWarning(SC_ERR_INVALID_ARGUMENT, + "No output module named %s, ignoring", output->val); + continue; + } + + OutputCtx *output_ctx = NULL; + if (module->InitFunc != NULL) { + output_ctx = module->InitFunc(output_config); + if (output_ctx == NULL) { + /* In most cases the init function will have logged the + * error. Maybe we should exit on init errors? */ + continue; } - tm_module = TmModuleGetByName(module->name); - if (tm_module == NULL) { - SCLogError(SC_ERR_INVALID_ARGUMENT, + } + tm_module = TmModuleGetByName(module->name); + if (tm_module == NULL) { + SCLogError(SC_ERR_INVALID_ARGUMENT, "TmModuleGetByName for %s failed", module->name); - exit(EXIT_FAILURE); - } - RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput)); - if (runmode_output == NULL) - return; - runmode_output->tm_module = tm_module; - runmode_output->output_ctx = output_ctx; - TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries); + exit(EXIT_FAILURE); } + RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput)); + if (runmode_output == NULL) + return; + runmode_output->tm_module = tm_module; + runmode_output->output_ctx = output_ctx; + TAILQ_INSERT_TAIL(&RunModeOutputs, runmode_output, entries); } }