]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: check for multiple instances of drop and tls
authorVictor Julien <victor@inliniac.net>
Thu, 30 Jan 2014 12:49:42 +0000 (13:49 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 30 Jan 2014 12:49:42 +0000 (13:49 +0100)
Both the drop and tls logs are currently not designed to have multiple
instances running. So until that is changed, error out if more than one
instance is started.

src/log-droplog.c
src/log-tlslog.c
src/output-json-drop.c
src/output-tlslog.c
src/output.c
src/output.h

index 086608318b4a469cdef98d69cf516d697f604a36..740b06cb2a24f15631adcf8f56ca5e649003638d 100644 (file)
@@ -136,6 +136,12 @@ static void LogDropLogDeInitCtx(OutputCtx *output_ctx)
  */
 static OutputCtx *LogDropLogInitCtx(ConfNode *conf)
 {
+    if (OutputDropLoggerEnable() != 0) {
+        SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
+            "can be enabled");
+        return NULL;
+    }
+
     LogFileCtx *logfile_ctx = LogFileNewCtx();
     if (logfile_ctx == NULL) {
         SCLogDebug("LogDropLogInitCtx: Could not create new LogFileCtx");
index fa90a14a9cafc83052b851f1ce63a278bac0b12c..a95a0d5b2f2134e785924a16a0d17044a4d9f045 100644 (file)
@@ -401,6 +401,12 @@ static void LogTlsLogExitPrintStats(ThreadVars *tv, void *data)
  * */
 static OutputCtx *LogTlsLogInitCtx(ConfNode *conf)
 {
+    if (OutputTlsLoggerEnable() != 0) {
+        SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'tls' logger "
+            "can be enabled");
+        return NULL;
+    }
+
     LogFileCtx* file_ctx = LogFileNewCtx();
 
     if (file_ctx == NULL) {
index e8a93bc7aa6cbf091c5a2c500c2489fee896f458..ef00f6e30ee0598cac41fc3245bdaba3767180da 100644 (file)
@@ -194,6 +194,12 @@ static void JsonDropLogDeInitCtx(OutputCtx *output_ctx)
 #define DEFAULT_LOG_FILENAME "drop.json"
 static OutputCtx *JsonDropLogInitCtx(ConfNode *conf)
 {
+    if (OutputDropLoggerEnable() != 0) {
+        SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
+            "can be enabled");
+        return NULL;
+    }
+
     LogFileCtx *logfile_ctx = LogFileNewCtx();
     if (logfile_ctx == NULL) {
         return NULL;
@@ -216,6 +222,12 @@ static OutputCtx *JsonDropLogInitCtx(ConfNode *conf)
 
 static OutputCtx *JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
 {
+    if (OutputDropLoggerEnable() != 0) {
+        SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
+            "can be enabled");
+        return NULL;
+    }
+
     AlertJsonThread *ajt = parent_ctx->data;
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
index 0fe95fb162118ebd8cd6725a0287b251c38746b1..016f6df593e762e4eec0284fb2192a6790f1ccd8 100644 (file)
@@ -217,6 +217,12 @@ static TmEcode JsonTlsLogThreadDeinit(ThreadVars *t, void *data)
 #define DEFAULT_LOG_FILENAME "tls.json"
 OutputCtx *OutputTlsLogInit(ConfNode *conf)
 {
+    if (OutputTlsLoggerEnable() != 0) {
+        SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'tls' logger "
+            "can be enabled");
+        return NULL;
+    }
+
     LogFileCtx *file_ctx = LogFileNewCtx();
     if(file_ctx == NULL) {
         SCLogError(SC_ERR_HTTP_LOG_GENERIC, "couldn't create new file_ctx");
@@ -258,6 +264,12 @@ OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
 {
     AlertJsonThread *ajt = parent_ctx->data;
 
+    if (OutputTlsLoggerEnable() != 0) {
+        SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'tls' logger "
+            "can be enabled");
+        return NULL;
+    }
+
     OutputTlsCtx *tls_ctx = SCMalloc(sizeof(OutputTlsCtx));
     if (unlikely(tls_ctx == NULL))
         return NULL;
index 043e37d80ae4df6e50f7954ae334932a0be4acd9..b6960d75e0e2974d04e0fa93d405adf918547e4a 100644 (file)
@@ -374,3 +374,22 @@ OutputDeregisterAll(void)
         SCFree(module);
     }
 }
+
+static int drop_loggers = 0;
+
+int OutputDropLoggerEnable(void) {
+    if (drop_loggers)
+        return -1;
+    drop_loggers++;
+    return 0;
+}
+
+static int tls_loggers = 0;
+
+int OutputTlsLoggerEnable(void) {
+    if (tls_loggers)
+        return -1;
+    tls_loggers++;
+    return 0;
+}
+
index e0f2f6794a839dc8589db6be1d728f572ba861d0..d87178135c564acd4168865533ed80647e2cfc7a 100644 (file)
@@ -83,4 +83,7 @@ void OutputRegisterFiledataSubModule(const char *parent_name, const char *name,
 OutputModule *OutputGetModuleByConfName(const char *name);
 void OutputDeregisterAll(void);
 
+int OutputDropLoggerEnable(void);
+int OutputTlsLoggerEnable(void);
+
 #endif /* ! __OUTPUT_H__ */