From 3d2834a232df34af3edbb2c4e8be3eb23e9ac6f7 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Thu, 11 Feb 2016 14:45:23 -0600 Subject: [PATCH] json: use top-level sensor-name if provided. Currently the default configuration file contains a "sensor-name" at the root of the configuration file, however, eve-log will only use it if its specified under eve-log. Now we will look for it at the eve-log, if present we'll use it but log a deprecation warning, if its not present we'll look for sensor-name at the root of the configuration. --- src/output-json.c | 10 ++++++++++ src/util-error.c | 1 + src/util-error.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/output-json.c b/src/output-json.c index 7661725d52..3a24fcecfb 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -435,7 +435,17 @@ OutputCtx *OutputJsonInitCtx(ConfNode *conf) { OutputJsonCtx *json_ctx = SCCalloc(1, sizeof(OutputJsonCtx));; + /* First lookup a sensor-name value in this outputs configuration + * node (deprecated). If that fails, lookup the global one. */ const char *sensor_name = ConfNodeLookupChildValue(conf, "sensor-name"); + if (sensor_name != NULL) { + SCLogWarning(SC_ERR_DEPRECATED_CONF, + "Found deprecated eve-log setting \"sensor-name\". " + "Please set sensor-name globally."); + } + else { + ConfGet("sensor-name", (char **)&sensor_name); + } if (unlikely(json_ctx == NULL)) { SCLogDebug("AlertJsonInitCtx: Could not create new LogFileCtx"); diff --git a/src/util-error.c b/src/util-error.c index 8ea229b598..5b03c5ad15 100644 --- a/src/util-error.c +++ b/src/util-error.c @@ -314,6 +314,7 @@ const char * SCErrorToString(SCError err) CASE_CODE (SC_ERR_INVALID_RULE_ARGUMENT); CASE_CODE (SC_ERR_STATS_LOG_NEGATED); CASE_CODE (SC_ERR_JSON_STATS_LOG_NEGATED); + CASE_CODE (SC_ERR_DEPRECATED_CONF); } return "UNKNOWN_ERROR"; diff --git a/src/util-error.h b/src/util-error.h index fec09d04a7..0dcfb674d1 100644 --- a/src/util-error.h +++ b/src/util-error.h @@ -304,6 +304,7 @@ typedef enum { SC_ERR_MT_NO_MAPPING, SC_ERR_STATS_LOG_NEGATED, /** When totals and threads are both NO in yaml **/ SC_ERR_JSON_STATS_LOG_NEGATED, /** When totals and threads are both NO in yaml **/ + SC_ERR_DEPRECATED_CONF, /**< Deprecated configuration parameter. */ } SCError; const char *SCErrorToString(SCError);