char SCClassConfClasstypeHashCompareFunc(void *data1, uint16_t datalen1,
void *data2, uint16_t datalen2);
void SCClassConfClasstypeHashFree(void *ch);
-static char *SCClassConfGetConfFilename(void);
+static char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx);
void SCClassConfInit(void)
{
* instead use an input stream against a buffer containing the
* classification strings */
if (fd == NULL) {
- filename = SCClassConfGetConfFilename();
+ filename = SCClassConfGetConfFilename(de_ctx);
if ( (fd = fopen(filename, "r")) == NULL) {
#ifdef UNITTESTS
if (RunmodeIsUnittests())
* \retval log_filename Pointer to a string containing the path for the
* Classification Config file.
*/
-static char *SCClassConfGetConfFilename(void)
+static char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx)
{
char *log_filename = NULL;
-
- if (ConfGet("classification-file", &log_filename) != 1) {
- log_filename = (char *)SC_CLASS_CONF_DEF_CONF_FILEPATH;
+ char config_value[256] = "";
+
+ if (de_ctx != NULL && strlen(de_ctx->config_prefix) > 0) {
+ snprintf(config_value, sizeof(config_value),
+ "%s.classification-file", de_ctx->config_prefix);
+
+ /* try loading prefix setting, fall back to global if that
+ * fails. */
+ if (ConfGet(config_value, &log_filename) != 1) {
+ if (ConfGet("classification-file", &log_filename) != 1) {
+ log_filename = (char *)SC_CLASS_CONF_DEF_CONF_FILEPATH;
+ }
+ }
+ } else {
+ if (ConfGet("classification-file", &log_filename) != 1) {
+ log_filename = (char *)SC_CLASS_CONF_DEF_CONF_FILEPATH;
+ }
}
return log_filename;