]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
tls-store: backward compatibility
authorEric Leblond <eric@regit.org>
Tue, 14 Jul 2015 20:35:32 +0000 (22:35 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 20 Jul 2015 09:45:21 +0000 (11:45 +0200)
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'.

src/runmodes.c

index 5f9b201d51784dd67da362c1aae7301999f3c396..e6ff72872b332a9d04b114a541da9f03c68ada23 100644 (file)
@@ -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);
+            }
+        }
+    }
+
 }
 
 /**