tls-store: backward compatibility

This patch implements backward compatibility in suricata.yaml
file. In case the new 'tls-store' output is not present in the
YAML we have to use the value defined in 'tls-log'.
pull/1600/head
Eric Leblond 10 years ago committed by Victor Julien
parent 4db0a35f25
commit b77cd22b98

@ -695,6 +695,8 @@ void RunModeInitializeOutputs(void)
ConfNode *output, *output_config;
const char *enabled;
char tls_log_enabled = 0;
char tls_store_present = 0;
TAILQ_FOREACH(output, &outputs->head, next) {
@ -706,6 +708,10 @@ void RunModeInitializeOutputs(void)
exit(1);
}
if (strcmp(output->val, "tls-store") == 0) {
tls_store_present = 1;
}
enabled = ConfNodeLookupChildValue(output_config, "enabled");
if (enabled == NULL || !ConfValIsTrue(enabled)) {
continue;
@ -742,6 +748,8 @@ void RunModeInitializeOutputs(void)
"files installed to add lua support.");
continue;
#endif
} else if (strcmp(output->val, "tls-log") == 0) {
tls_log_enabled = 1;
}
OutputModule *module = OutputGetModuleByConfName(output->val);
@ -847,6 +855,40 @@ void RunModeInitializeOutputs(void)
SetupOutput(module->name, module, output_ctx);
}
}
/* Backward compatibility code */
if (!tls_store_present && tls_log_enabled) {
/* old YAML with no "tls-store" in outputs. "tls-log" value needs
* to be started using 'tls-log' config as own config */
SCLogWarning(SC_ERR_CONF_YAML_ERROR,
"Please use 'tls-store' in YAML to configure TLS storage");
TAILQ_FOREACH(output, &outputs->head, next) {
output_config = ConfNodeLookupChild(output, output->val);
if (strcmp(output->val, "tls-log") == 0) {
OutputModule *module = OutputGetModuleByConfName("tls-store");
if (module == NULL) {
SCLogWarning(SC_ERR_INVALID_ARGUMENT,
"No output module named %s, ignoring", "tls-store");
continue;
}
OutputCtx *output_ctx = NULL;
if (module->InitFunc != NULL) {
output_ctx = module->InitFunc(output_config);
if (output_ctx == NULL) {
continue;
}
}
AddOutputToFreeList(module, output_ctx);
SetupOutput(module->name, module, output_ctx);
}
}
}
}
/**

Loading…
Cancel
Save