-- added path to dynamically loaded plugins output with --list-plugins
-- commented out mpse start up foo - needs reformatting
-- added snort.detach() and fixed -j parsing
+-- various parsing changes for improved error handling
122
-- pulled thread pinning from Josh
load_overrides(L, s);
run_config(L, "_G");
-
- if ( int k = ModuleManager::get_errors() )
- {
- if ( snort_is_starting() )
- FatalError("see prior %d errors\n", k);
- }
}
//-------------------------------------------------------------------------
// Must be after CodecManager::instantiate()
if ( !InspectorManager::configure(snort_conf) )
- FatalError("can't initialize inspectors\n");
+ ParseError("can't initialize inspectors");
- if ( ScLogVerbose() )
+ else if ( ScLogVerbose() )
InspectorManager::print_config(snort_conf);
ParseRules(snort_conf);
SFAT_Start();
#ifdef PPM_MGR
- PPM_PRINT_CFG(&snort_conf->ppm_cfg);
+ //PPM_PRINT_CFG(&snort_conf->ppm_cfg);
#endif
/* Finish up the pcap list and put in the queues */
// FIXIT-L stuff like this that is also done in snort_config.cc::VerifyReload()
// should be refactored
if ((snort_conf->bpf_filter == NULL) && (snort_conf->bpf_file != NULL))
- snort_conf->bpf_filter = read_infile(snort_conf->bpf_file);
+ snort_conf->bpf_filter = read_infile("packets.bpf_file", snort_conf->bpf_file);
if (snort_conf->bpf_filter != NULL)
LogMessage("Snort BPF option: %s\n", snort_conf->bpf_filter);
}
#ifdef PPM_MGR
- PPM_PRINT_CFG(&sc->ppm_cfg);
+ //PPM_PRINT_CFG(&sc->ppm_cfg);
#endif
return sc;
}
if ((sc->bpf_filter == NULL) && (sc->bpf_file != NULL))
- sc->bpf_filter = read_infile(sc->bpf_file);
+ sc->bpf_filter = read_infile("packets.bpf_file", sc->bpf_file);
if ((sc->bpf_filter != NULL) && (snort_conf->bpf_filter != NULL))
{
{
if ( !mod->set(fqn, val, s_config) )
{
- ErrorMessage("ERROR: %s is invalid\n", fqn);
+ ParseError("%s is invalid", fqn);
++s_errors;
}
if ( !p )
{
- ErrorMessage("ERROR can't find %s\n", fqn);
+ ParseError("can't find %s", fqn);
++s_errors;
return false;
}
}
if ( v.get_type() == Value::VT_STR )
- ErrorMessage("ERROR invalid %s = '%s'\n", fqn, v.get_string());
+ ParseError("invalid %s = '%s'", fqn, v.get_string());
else if ( v.get_real() == v.get_long() )
- ErrorMessage("ERROR invalid %s = %ld\n", fqn, v.get_long());
+ ParseError("invalid %s = %ld", fqn, v.get_long());
else
- ErrorMessage("ERROR invalid %s = %g\n", fqn, v.get_real());
+ ParseError("invalid %s = %g", fqn, v.get_real());
++s_errors;
return false;
if ( !p )
{
- ParseError("can't find %s\n", s);
+ ParseError("can't find %s", s);
return false;
}
else if ((idx > 0) && (p->type == Parameter::PT_TABLE))
{
- ParseError("%s is a table. All elements must be named\n", s);
+ ParseError("%s is a table; all elements must be named", s);
return false;
}
}
// (we don't want to suppress it because it could mean something is broken)
void ModuleManager::load_rules(SnortConfig* sc)
{
- // FIXIT-M callers of ParseConfigString() should not have to push parse loc
+ s_modules.sort(comp_gids);
push_parse_location("builtin");
for ( auto p : s_modules )
void PluginManager::instantiate(
const BaseApi* api, Module* mod, SnortConfig* sc, const char* name)
{
- assert(api->type == PT_INSPECTOR);
- InspectorManager::instantiate((InspectApi*)api, mod, sc, name);
+ if ( api->type == PT_INSPECTOR )
+ InspectorManager::instantiate((InspectApi*)api, mod, sc, name);
+
+ else if ( api->type == PT_DATA )
+ // FIXIT-H instantiate PT_DATA with name
+ DataManager::instantiate((DataApi*)api, mod, sc/*, name*/);
+
+ else
+ assert(false);
}
Location loc(file, line);
files.push(loc);
+ LogMessage("Loading %s:\n", file);
}
void pop_parse_location()
{
if ( !files.empty() )
+ {
+ Location& loc = files.top();
+ LogMessage("Finished %s.\n", loc.file.c_str());
files.pop();
+ }
}
void inc_parse_position()
if ( !fname || !*fname )
return;
- LogMessage("Loading %s:\n", fname);
push_parse_location(fname);
sh->configure(sc);
pop_parse_location();
unsigned file_line;
get_parse_location(file_name, file_line);
- if (file_name != NULL)
- LogMessage("ERROR: %s(%d) %s\n", file_name, file_line, buf);
+ if (file_line )
+ LogMessage("ERROR: %s:%d %s\n", file_name, file_line, buf);
else
LogMessage("ERROR: %s\n", buf);
unsigned file_line;
get_parse_location(file_name, file_line);
- if (file_name != NULL)
- LogMessage("WARNING: %s(%d) %s\n", file_name, file_line, buf);
+ if ( file_line )
+ LogMessage("WARNING: %s:%d %s\n", file_name, file_line, buf);
else
LogMessage("WARNING: %s\n", buf);
const char* get_parse_file();
void get_parse_location(const char*& name, unsigned& line);
-void push_parse_location(const char* name, unsigned line = 1);
+void push_parse_location(const char* name, unsigned line = 0);
void pop_parse_location();
void inc_parse_position();
{ "bounce", Parameter::PT_BOOL, nullptr, "false",
"check for bounces" },
- { "bounce_to", Parameter::PT_TABLE, client_bounce_params, nullptr,
+ { "bounce_to", Parameter::PT_LIST, client_bounce_params, nullptr,
"allow bounces to CIDRs / ports" },
{ "ignore_telnet_erase_cmds", Parameter::PT_BOOL, nullptr, "false",
/****************************************************************************
*
- * Function: read_infile(char *)
+ * Function: read_infile(const char* key, const char* file)
*
* Purpose: Reads the BPF filters in from a file. Ripped from tcpdump.
*
* Returns: the processed BPF string
*
****************************************************************************/
-char *read_infile(char *fname)
+char *read_infile(const char* key, const char* fname)
{
int fd, cc;
char *cp, *cmt;
if(fd < 0)
{
- ParseError("can't open %s: %s\n", fname, get_error(errno));
+ ParseError("can't open %s = %s: %s\n", key, fname, get_error(errno));
return nullptr;
}
void ts_print(register const struct timeval *, char *);
void strip(char *);
void CheckLogDir(void);
-char *read_infile(char *);
+char *read_infile(const char* key, const char* fname);
void CleanupProtoNames(void);
void CreatePidFile(pid_t);
void ClosePidFile(void);