Bug #15 » 0003-fix-for-unclear-error-messages-bug-15.patch
| src/alert-debuglog.c | ||
|---|---|---|
|
if(initdata == NULL)
|
||
|
{
|
||
|
printf("Error getting context for the file\n");
|
||
|
SCLogError(SC_ERR_DEBUG_LOG_GENERIC_ERROR, "Error getting context for "
|
||
|
"DebugLog. \"initdata\" argument NULL");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/** Use the Ouptut Context (file pointer and mutex) */
|
||
| ... | ... | |
|
if(file_ctx == NULL)
|
||
|
{
|
||
|
printf("AlertDebuglogInitCtx: Couldn't create new file_ctx\n");
|
||
|
SCLogError(SC_ERR_DEBUG_LOG_GENERIC_ERROR, "AlertDebuglogInitCtx: Couldn't "
|
||
|
"create new file_ctx");
|
||
|
return NULL;
|
||
|
}
|
||
| ... | ... | |
|
snprintf(log_path, PATH_MAX, "%s/%s", log_dir, DEFAULT_LOG_FILENAME);
|
||
|
file_ctx->fp = fopen(log_path, "w");
|
||
|
if (file_ctx->fp == NULL) {
|
||
|
printf("ERROR: failed to open %s: %s\n", log_path, strerror(errno));
|
||
|
SCLogError(SC_ERR_FOPEN, "ERROR: failed to open %s: %s", log_path,
|
||
|
strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
| src/alert-fastlog.c | ||
|---|---|---|
|
memset(aft, 0, sizeof(AlertFastlogThread));
|
||
|
if(initdata == NULL)
|
||
|
{
|
||
|
printf("Error getting context for the file\n");
|
||
|
SCLogError(SC_ERR_FAST_LOG_GENERIC_ERROR, "Error getting context for "
|
||
|
"AlertFastLog. \"initdata\" argument NULL");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/** Use the Ouptut Context (file pointer and mutex) */
|
||
| ... | ... | |
|
if(file_ctx == NULL)
|
||
|
{
|
||
|
printf("AlertFastlogInitCtx: Couldn't create new file_ctx\n");
|
||
|
SCLogError(SC_ERR_FAST_LOG_GENERIC_ERROR, "AlertFastlogInitCtx: Couldn't "
|
||
|
"create new file_ctx");
|
||
|
return NULL;
|
||
|
}
|
||
| ... | ... | |
|
file_ctx->fp = fopen(log_path, "w");
|
||
|
if (file_ctx->fp == NULL) {
|
||
|
printf("ERROR: failed to open %s: %s\n", log_path, strerror(errno));
|
||
|
SCLogError(SC_ERR_FOPEN, "ERROR: failed to open %s: %s", log_path,
|
||
|
strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
| src/alert-unified-alert.c | ||
|---|---|---|
|
#include "util-unittest.h"
|
||
|
#include "util-time.h"
|
||
|
#include "util-error.h"
|
||
|
#include "util-debug.h"
|
||
|
#define DEFAULT_LOG_FILENAME "unified.alert"
|
||
| ... | ... | |
|
ret = fwrite(&hdr, sizeof(hdr), 1, aun->file_ctx->fp);
|
||
|
if (ret != 1) {
|
||
|
printf("Error: fwrite failed: ret = %" PRId32 ", %s\n", ret, strerror(errno));
|
||
|
SCLogError(SC_ERR_FWRITE, "Error: fwrite failed: ret = %" PRId32 ", %s",
|
||
|
ret, strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
fflush(aun->file_ctx->fp);
|
||
| ... | ... | |
|
int AlertUnifiedAlertRotateFile(ThreadVars *t, AlertUnifiedAlertThread *aun) {
|
||
|
if (AlertUnifiedAlertCloseFile(t,aun) < 0) {
|
||
|
printf("Error: AlertUnifiedAlertCloseFile failed\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_ALERT_GENERIC_ERROR,
|
||
|
"Error: AlertUnifiedAlertCloseFile failed");
|
||
|
return -1;
|
||
|
}
|
||
|
if (AlertUnifiedAlertOpenFileCtx(aun->file_ctx,aun->file_ctx->config_file) < 0) {
|
||
|
printf("Error: AlertUnifiedLogOpenFileCtx, open new log file failed\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_ALERT_GENERIC_ERROR,
|
||
|
"Error: AlertUnifiedLogOpenFileCtx, open new log file failed");
|
||
|
return -1;
|
||
|
}
|
||
|
if (AlertUnifiedAlertWriteFileHeader(t, aun) < 0) {
|
||
|
printf("Error: AlertUnifiedLogAppendFile, write unified header failed\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_ALERT_GENERIC_ERROR, "Error: "
|
||
|
"AlertUnifiedLogAppendFile, write unified header failed");
|
||
|
return -1;
|
||
|
}
|
||
| ... | ... | |
|
/* write and flush so it's written immediately */
|
||
|
ret = fwrite(&hdr, sizeof(hdr), 1, aun->file_ctx->fp);
|
||
|
if (ret != 1) {
|
||
|
printf("Error: fwrite failed: %s\n", strerror(errno));
|
||
|
SCLogError(SC_ERR_FWRITE, "Error: fwrite failed: %s", strerror(errno));
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/* force writing to disk so barnyard will not read half
|
||
| ... | ... | |
|
if(initdata == NULL)
|
||
|
{
|
||
|
printf("Error getting context for the file\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_ALERT_GENERIC_ERROR, "Error getting context for "
|
||
|
"UnifiedAlert. \"initdata\" argument NULL");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/** Use the Ouptut Context (file pointer and mutex) */
|
||
| ... | ... | |
|
/** Write Unified header */
|
||
|
int ret = AlertUnifiedAlertWriteFileHeader(t, aun);
|
||
|
if (ret != 0) {
|
||
|
printf("Error: AlertUnifiedLogWriteFileHeader failed.\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_ALERT_GENERIC_ERROR,
|
||
|
"Error: AlertUnifiedLogWriteFileHeader failed");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
| ... | ... | |
|
LogFileCtx *file_ctx = LogFileNewCtx();
|
||
|
if (file_ctx == NULL) {
|
||
|
printf("AlertUnifiedAlertInitCtx: Couldn't create new file_ctx\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_ALERT_GENERIC_ERROR,
|
||
|
"AlertUnifiedAlertInitCtx: Couldn't create new file_ctx");
|
||
|
return NULL;
|
||
|
}
|
||
| ... | ... | |
|
/* XXX filename & location */
|
||
|
file_ctx->fp = fopen(filename, "wb");
|
||
|
if (file_ctx->fp == NULL) {
|
||
|
printf("Error: fopen %s failed: %s\n", filename, strerror(errno)); /* XXX errno threadsafety? */
|
||
|
SCLogError(SC_ERR_FOPEN, "ERROR: failed to open %s: %s", filename,
|
||
|
strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
| src/alert-unified-log.c | ||
|---|---|---|
|
#include "util-unittest.h"
|
||
|
#include "util-time.h"
|
||
|
#include "util-debug.h"
|
||
|
#include "util-error.h"
|
||
|
#define DEFAULT_LOG_FILENAME "unified.log"
|
||
| ... | ... | |
|
memset(aun, 0, sizeof(AlertUnifiedLogThread));
|
||
|
if(initdata == NULL)
|
||
|
{
|
||
|
printf("Error getting context for the file\n");
|
||
|
SCLogError(SC_ERR_UNIFIED_LOG_GENERIC_ERROR, "Error getting context for "
|
||
|
"UnifiedLog. \"initdata\" argument NULL");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/** Use the Ouptut Context (file pointer and mutex) */
|
||
| ... | ... | |
|
/* XXX filename & location */
|
||
|
file_ctx->fp = fopen(filename, "wb");
|
||
|
if (file_ctx->fp == NULL) {
|
||
|
printf("Error: fopen %s failed: %s\n", filename, strerror(errno)); /* XXX errno threadsafety? */
|
||
|
SCLogError(SC_ERR_FOPEN, "ERROR: failed to open %s: %s", filename,
|
||
|
strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
| src/alert-unified2-alert.c | ||
|---|---|---|
|
#include "alert-unified2-alert.h"
|
||
|
#include "decode-ipv4.h"
|
||
|
#include "util-error.h"
|
||
|
#include "util-debug.h"
|
||
|
#include "util-time.h"
|
||
|
#ifndef IPPROTO_SCTP
|
||
| ... | ... | |
|
int Unified2AlertRotateFile(ThreadVars *t, Unified2AlertThread *aun) {
|
||
|
if (Unified2AlertCloseFile(t,aun) < 0) {
|
||
|
printf("Error: Unified2AlertCloseFile failed\n");
|
||
|
SCLogError(SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR,
|
||
|
"Error: Unified2AlertCloseFile failed");
|
||
|
return -1;
|
||
|
}
|
||
|
if (Unified2AlertOpenFileCtx(aun->file_ctx,aun->file_ctx->config_file) < 0) {
|
||
|
printf("Error: Unified2AlertOpenFileCtx, open new log file failed\n");
|
||
|
SCLogError(SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR,
|
||
|
"Error: Unified2AlertOpenFileCtx, open new log file failed");
|
||
|
return -1;
|
||
|
}
|
||
|
return 0;
|
||
| ... | ... | |
|
ret = fwrite(write_buffer,len, 1, aun->file_ctx->fp);
|
||
|
if (ret != 1) {
|
||
|
printf("Error: fwrite failed: %s\n", strerror(errno));
|
||
|
SCLogError(SC_ERR_FWRITE, "Error: fwrite failed: %s", strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
| ... | ... | |
|
ret = fwrite(write_buffer,len, 1, aun->file_ctx->fp);
|
||
|
if (ret != 1) {
|
||
|
printf("Error: fwrite failed: %s\n", strerror(errno));
|
||
|
SCLogError(SC_ERR_FWRITE, "Error: fwrite failed: %s", strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
| ... | ... | |
|
ret = fwrite(write_buffer,len, 1, aun->file_ctx->fp);
|
||
|
if (ret != 1) {
|
||
|
printf("Error: fwrite failed: %s\n", strerror(errno));
|
||
|
SCLogError(SC_ERR_FWRITE, "Error: fwrite failed: %s", strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
| ... | ... | |
|
memset(aun, 0, sizeof(Unified2AlertThread));
|
||
|
if(initdata == NULL)
|
||
|
{
|
||
|
printf("Error getting context for the file\n");
|
||
|
SCLogError(SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR, "Error getting context for "
|
||
|
"Unified2Alert. \"initdata\" argument NULL");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/** Use the Ouptut Context (file pointer and mutex) */
|
||
| ... | ... | |
|
if(file_ctx == NULL)
|
||
|
{
|
||
|
printf("Unified2AlertInitCtx: Couldn't create new file_ctx\n");
|
||
|
SCLogError(SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR, "Unified2AlertInitCtx: "
|
||
|
"Couldn't create new file_ctx");
|
||
|
return NULL;
|
||
|
}
|
||
| ... | ... | |
|
/* XXX filename & location */
|
||
|
file_ctx->fp = fopen(filename, "wb");
|
||
|
if (file_ctx->fp == NULL) {
|
||
|
printf("Error: fopen %s failed: %s\n", filename, strerror(errno)); /* XXX errno threadsafety? */
|
||
|
SCLogError(SC_ERR_FOPEN, "ERROR: failed to open %s: %s", filename,
|
||
|
strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
goto error;
|
||
|
if (strcmp(filename, lf->filename) == 0) {
|
||
|
printf("filename \"%s\" == \"%s\": ", filename, lf->filename);
|
||
|
SCLogError(SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR,
|
||
|
"filename \"%s\" == \"%s\": ", filename, lf->filename);
|
||
|
goto error;
|
||
|
}
|
||
| src/log-httplog.c | ||
|---|---|---|
|
if(initdata == NULL)
|
||
|
{
|
||
|
printf("Error getting context for the file\n");
|
||
|
SCLogError(SC_ERR_HTTP_LOG_GENERIC_ERROR, "Error getting context for "
|
||
|
"HTTPLog. \"initdata\" argument NULL");
|
||
|
return TM_ECODE_FAILED;
|
||
|
}
|
||
|
/** Use the Ouptut Context (file pointer and mutex) */
|
||
| ... | ... | |
|
if(file_ctx == NULL)
|
||
|
{
|
||
|
printf("LogHttplogInitCtx: Couldn't create new file_ctx\n");
|
||
|
SCLogError(SC_ERR_HTTP_LOG_GENERIC_ERROR, "LogHttplogInitCtx: Couldn't "
|
||
|
"create new file_ctx");
|
||
|
return NULL;
|
||
|
}
|
||
| ... | ... | |
|
file_ctx->fp = fopen(log_path, "w");
|
||
|
if (file_ctx->fp == NULL) {
|
||
|
printf("ERROR: failed to open %s: %s\n", log_path, strerror(errno));
|
||
|
SCLogError(SC_ERR_FOPEN, "ERROR: failed to open %s: %s", log_path,
|
||
|
strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
if(file_ctx->config_file == NULL)
|
||
| src/util-error.c | ||
|---|---|---|
|
CASE_CODE (SC_ERR_REASSEMBLY_FAILED);
|
||
|
CASE_CODE (SC_ERR_POOL_INIT_FAILED);
|
||
|
CASE_CODE (SC_UNIMPLEMENTED);
|
||
|
CASE_CODE (SC_ERR_FAST_LOG_GENERIC_ERROR);
|
||
|
CASE_CODE (SC_ERR_DEBUG_LOG_GENERIC_ERROR);
|
||
|
CASE_CODE (SC_ERR_UNIFIED_LOG_GENERIC_ERROR);
|
||
|
CASE_CODE (SC_ERR_HTTP_LOG_GENERIC_ERROR);
|
||
|
CASE_CODE (SC_ERR_UNIFIED_ALERT_GENERIC_ERROR);
|
||
|
CASE_CODE (SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR);
|
||
|
CASE_CODE (SC_ERR_FWRITE);
|
||
|
CASE_CODE (SC_ERR_FOPEN);
|
||
|
default:
|
||
|
return "UNKNOWN_ERROR";
|
||
|
}
|
||
| src/util-error.h | ||
|---|---|---|
|
SC_NFQ_THREAD_INIT,
|
||
|
SC_ERR_DAEMON,
|
||
|
SC_UNIMPLEMENTED,
|
||
|
SC_ERR_FAST_LOG_GENERIC_ERROR,
|
||
|
SC_ERR_DEBUG_LOG_GENERIC_ERROR,
|
||
|
SC_ERR_UNIFIED_LOG_GENERIC_ERROR,
|
||
|
SC_ERR_HTTP_LOG_GENERIC_ERROR,
|
||
|
SC_ERR_UNIFIED_ALERT_GENERIC_ERROR,
|
||
|
SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR,
|
||
|
SC_ERR_FWRITE,
|
||
|
} SCError;
|
||
|
const char *SCErrorToString(SCError);
|
||