output/file: remove 'waldo' code

It was no longer used after "file-store v1" was removed.
pull/6935/head
Victor Julien 3 years ago
parent f9c04992c3
commit 97ef60cd9b

@ -61,10 +61,6 @@ typedef struct OutputFiledataLogger_ {
} OutputFiledataLogger;
static OutputFiledataLogger *list = NULL;
static char g_waldo[PATH_MAX] = "";
static SCMutex g_waldo_mutex = SCMUTEX_INITIALIZER;
static int g_waldo_init = 0;
static int g_waldo_deinit = 0;
int OutputRegisterFiledataLogger(LoggerId id, const char *name,
FiledataLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit,
@ -252,61 +248,6 @@ static TmEcode OutputFiledataLog(ThreadVars *tv, Packet *p, void *thread_data)
return TM_ECODE_OK;
}
/**
* \internal
*
* \brief Open the waldo file (if available) and load the file_id
*
* \param path full path for the waldo file
*/
static void LogFiledataLogLoadWaldo(const char *path)
{
char line[16] = "";
unsigned int id = 0;
FILE *fp = fopen(path, "r");
if (fp == NULL) {
SCLogInfo("couldn't open waldo: %s", strerror(errno));
SCReturn;
}
if (fgets(line, (int)sizeof(line), fp) != NULL) {
if (sscanf(line, "%10u", &id) == 1) {
SCLogInfo("id %u", id);
SC_ATOMIC_SET(g_file_store_id, id);
}
}
fclose(fp);
}
/**
* \internal
*
* \brief Store the waldo file based on the file_id
*
* \param path full path for the waldo file
*/
static void LogFiledataLogStoreWaldo(const char *path)
{
char line[16] = "";
if (SC_ATOMIC_GET(g_file_store_id) == 1) {
SCReturn;
}
FILE *fp = fopen(path, "w");
if (fp == NULL) {
SCLogInfo("couldn't open waldo: %s", strerror(errno));
SCReturn;
}
snprintf(line, sizeof(line), "%u\n", SC_ATOMIC_GET(g_file_store_id));
if (fwrite(line, strlen(line), 1, fp) != 1) {
SCLogError(SC_ERR_FWRITE, "fwrite failed: %s", strerror(errno));
}
fclose(fp);
}
/** \brief thread init for the tx logger
* This will run the thread init functions for the individual registered
* loggers */
@ -356,56 +297,6 @@ static TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, const void *initdata,
logger = logger->next;
}
SCMutexLock(&g_waldo_mutex);
if (g_waldo_init == 0) {
ConfNode *node = ConfGetNode("file-store-waldo");
if (node == NULL) {
ConfNode *outputs = ConfGetNode("outputs");
if (outputs) {
ConfNode *output;
TAILQ_FOREACH(output, &outputs->head, next) {
/* we only care about file and file-store */
if (!(strcmp(output->val, "file") == 0 || strcmp(output->val, "file-store") == 0))
continue;
ConfNode *file = ConfNodeLookupChild(output, output->val);
BUG_ON(file == NULL);
if (file == NULL) {
SCLogDebug("file-store failed, lets try 'file'");
file = ConfNodeLookupChild(outputs, "file");
if (file == NULL)
SCLogDebug("file failed as well, giving up");
}
if (file != NULL) {
node = ConfNodeLookupChild(file, "waldo");
if (node == NULL)
SCLogDebug("no waldo node");
}
}
}
}
if (node != NULL) {
const char *s_default_log_dir = NULL;
s_default_log_dir = ConfigGetLogDirectory();
const char *waldo = node->val;
SCLogDebug("loading waldo %s", waldo);
if (waldo != NULL && strlen(waldo) > 0) {
if (PathIsAbsolute(waldo)) {
snprintf(g_waldo, sizeof(g_waldo), "%s", waldo);
} else {
snprintf(g_waldo, sizeof(g_waldo), "%s/%s", s_default_log_dir, waldo);
}
SCLogDebug("loading waldo file %s", g_waldo);
LogFiledataLogLoadWaldo(g_waldo);
}
}
g_waldo_init = 1;
}
SCMutexUnlock(&g_waldo_mutex);
return TM_ECODE_OK;
}
@ -426,16 +317,6 @@ static TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, void *thread_data)
logger = logger->next;
}
SCMutexLock(&g_waldo_mutex);
if (g_waldo_deinit == 0) {
if (strlen(g_waldo) > 0) {
SCLogDebug("we have a waldo at %s", g_waldo);
LogFiledataLogStoreWaldo(g_waldo);
}
g_waldo_deinit = 1;
}
SCMutexUnlock(&g_waldo_mutex);
#ifdef HAVE_MAGIC
MagicDeinitContext(op_thread_data->magic_ctx);
#endif

Loading…
Cancel
Save