Improve default-log-dir error checking and reporting.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 750600ab17
commit 1f09a88c93

@ -388,6 +388,12 @@ int main(int argc, char **argv)
fprintf(stderr, "ERROR: Failed to set log directory.\n");
exit(EXIT_FAILURE);
}
if (stat(optarg, &buf) != 0) {
SCLogError(SC_ERR_LOGDIR_CMDLINE, "The logging directory \"%s\" "
"upplied at the commandline (-l %s) doesn't "
"exist. Shutting down the engine.", optarg, optarg);
exit(EXIT_FAILURE);
}
break;
case 'q':
mode = MODE_NFQ;
@ -453,9 +459,9 @@ int main(int argc, char **argv)
if (ConfGet("default-log-dir", &log_dir) != 1)
log_dir = DEFAULT_LOG_DIR;
if (stat(log_dir, &buf) != 0) {
SCLogError(SC_ERR_STAT_ERROR, "The logging directory \"%s\" picked from "
"suricata.yaml(default-log-dir), doesn't exist. Shutting "
"down the engine", log_dir);
SCLogError(SC_ERR_LOGDIR_CONFIG, "The logging directory \"%s\" "
"supplied by %s (default-log-dir) doesn't exist. "
"Shutting down the engine", log_dir, conf_filename);
exit(EXIT_FAILURE);
}

@ -72,6 +72,8 @@ const char * SCErrorToString(SCError err)
CASE_CODE (SC_ERR_OFFSET_MISSING_CONTENT);
CASE_CODE (SC_ERR_NO_URICONTENT_NEGATION);
CASE_CODE (SC_ERR_FOPEN_ERROR);
CASE_CODE (SC_ERR_LOGDIR_CONFIG);
CASE_CODE (SC_ERR_LOGDIR_CMDLINE);
default:
return "UNKNOWN_ERROR";
}

@ -85,6 +85,8 @@ typedef enum {
SC_ERR_FOPEN_ERROR,
SC_ERR_HASH_TABLE_INIT_FAILED,
SC_ERR_STAT_ERROR,
SC_ERR_LOGDIR_CONFIG,
SC_ERR_LOGDIR_CMDLINE,
} SCError;
const char *SCErrorToString(SCError);

Loading…
Cancel
Save