-- misc FIXITs
-- converted wizard to fully stateful
-- implemented paf rescan upon auto service id
+-- changed StreamSplitter::max() from uint32_t to unsigned
+-- changed stream_tcp.paf_max to max_pdu
+-- added parse errors for module begin()/end() fails
+-- changed reload to not fatal on parse errors
120
-- tweaked --help!
# initialization
#--------------------------------------------------------------------------
-AC_INIT([snort], [2.10.120])
+AC_INIT([snort], [2.10.121])
AC_PREREQ([2.68])
AC_CONFIG_SRCDIR([src/main.h])
RejectModule() : Module(s_name, s_help, s_params) { };
bool begin(const char*, int, SnortConfig*);
- bool end(const char*, int, SnortConfig*);
bool set(const char*, Value&, SnortConfig*);
ProfileStats* get_profile() const
return true;
}
-bool RejectModule::end(const char*, int, SnortConfig*)
-{
- return ( flags != 0 );
-}
-
static const int rst[] =
{
REJ_RST_SRC,
*/
// module.h author Russ Combs <rucombs@cisco.com>
-// FIXIT-H add optional default config to modules
// FIXIT-M add trace param(s)
// FIXIT-M add memcap related
// FIXIT-L add set_default method
}
request.respond(".. reloading configuration\n");
SnortConfig* old = snort_conf;
- SnortConfig* sc = reload_config();
+ SnortConfig* sc = get_reload_config();
if ( !sc )
{
request.respond("== reload failed\n");
return 0;
}
+ proc_stats.conf_reloads++;
request.respond(".. swapping configuration\n");
swapper = new Swapper(old, sc);
if ( int k = get_parse_errors() )
{
- ParseAbort("see prior %d errors", k);
+ FatalError("see prior %d errors\n", k);
return false;
}
if ( ScTestMode() ||
run_config(L);
if ( int k = ModuleManager::get_errors() )
- FatalError("see prior %d errors\n", k);
+ {
+ if ( snort_is_starting() )
+ FatalError("see prior %d errors\n", k);
+ }
}
//-------------------------------------------------------------------------
// utility
//-------------------------------------------------------------------------
+bool snort_is_starting()
+{ return snort_initializing; }
+
#if 0
#ifdef HAVE_DAQ_ACQUIRE_WITH_META
static int MetaCallback(
#endif
#if 0
-// FIXIT-H restart foo
+// FIXIT-L restart foo
static void restart()
{
int daemon_mode = ScDaemonMode();
InitGroups(ScUid(), ScGid());
SnortUnprivilegedInit();
- if ( int k = get_parse_errors() )
- FatalError("see prior %d errors\n", k);
-
set_quick_exit(false);
}
// FIXIT-M refactor this so startup and reload call the same core function to
// instantiate things that can be reloaded
-static SnortConfig * get_reload_config(void)
+SnortConfig* get_reload_config()
{
- SnortConfig *sc = ParseSnortConf(snort_cmd_line_conf);
+ ModuleManager::reset_errors();
+ SnortConfig *sc = ParseSnortConf(snort_cmd_line_conf);
sc = MergeSnortConfs(snort_cmd_line_conf, sc);
init_policy(sc);
- if (VerifyReload(sc) == -1)
+ if ( ModuleManager::get_errors() || VerifyReload(sc) == -1 )
{
SnortConfFree(sc);
return NULL;
return NULL;
}
- FlowbitResetCounts();
+ FlowbitResetCounts(); // FIXIT-L updates global hash, put in sc
ParseRules(sc);
// FIXIT-L see SnortInit() on config printing
/* Need to do this after dynamic detection stuff is initialized, too */
IpsManager::verify(sc);
- ModuleManager::load_commands(snort_conf);
+ ModuleManager::load_commands(sc);
if ((sc->file_mask != 0) && (sc->file_mask != snort_conf->file_mask))
umask(sc->file_mask);
+ // FIXIT-L is this still needed?
/* Transfer any user defined rule type outputs to the new rule list */
{
RuleListNode *cur = snort_conf->rule_lists;
return sc;
}
-SnortConfig* reload_config()
-{
- SnortConfig* new_conf = get_reload_config();
-
- if ( new_conf )
- {
- proc_stats.conf_reloads++;
- snort_conf = new_conf;
- }
- return new_conf;
-}
-
//-------------------------------------------------------------------------
// runtime foo
//-------------------------------------------------------------------------
struct _daq_pkthdr;
typedef _daq_pkthdr DAQ_PktHdr_t;
-
-SnortConfig* reload_config();
+SnortConfig* get_reload_config();
void snort_setup(int argc, char* argv[]);
void snort_cleanup();
+bool snort_is_starting();
+
void snort_thread_init(const char* intf);
void snort_thread_term();
s_current = key;
}
- m->begin(s, idx, s_config);
+ if ( !m->begin(s, idx, s_config) )
+ {
+ ParseError("can't open %s", m->get_name());
+ return false;
+ }
return true;
}
if ( ModHook* h = get_hook(key.c_str()) )
{
- h->mod->end(s, idx, s_config);
+ if ( !h->mod->end(s, idx, s_config) )
+ {
+ ParseError("can't close %s", h->mod->get_name());
+ return;
+ }
if ( !idx && h->api && (key == s) )
PluginManager::instantiate(h->api, h->mod, s_config);
void ModuleManager::set_config(SnortConfig* sc)
{ s_config = sc; }
+void ModuleManager::reset_errors()
+{ s_errors = 0; }
+
unsigned ModuleManager::get_errors()
-{
- unsigned err = s_errors;
- s_errors = 0;
- return err;
-}
+{ return s_errors; }
void ModuleManager::list_modules()
{
static void load_commands(SnortConfig*);
static void load_rules(SnortConfig*);
static void set_config(SnortConfig*);
+
+ static void reset_errors();
static unsigned get_errors();
static void dump_stats(SnortConfig*);
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
---------------------------------------------------------------------------
+-- snort_config.lua author Russ Combs <rucombs@cisco.com>
---------------------------------------------------------------------------
-- Snort uses this to configure Lua settings into C++
SnortConfig * ParseSnortConf(const SnortConfig* boot_conf)
{
SnortConfig *sc = SnortConfNew();
- snort_conf = sc;
sc->logging_flags = boot_conf->logging_flags;
VarNode* tmp = boot_conf->var_list;
const StreamBuffer* reassemble(Flow* flow, unsigned total, unsigned offset, const uint8_t* data, unsigned len,
uint32_t flags, unsigned& copied);
bool is_paf() { return true; };
- uint32_t max() { return paf_max; };
+ unsigned max() { return paf_max; };
private:
void prepare_flush(NHttpFlowData* session_data, uint32_t* flush_offset, NHttpEnums::SourceId source_id,
NHttpEnums::SectionType section_type, bool tcp_close, uint64_t infractions, uint32_t num_octets);
NHttpInspect* const my_inspector;
uint8_t *section_buffer = nullptr;
- uint32_t paf_max = 63780;
+ unsigned paf_max = 63780;
};
#endif
uint32_t, uint32_t*)
{ return SEARCH; };
- uint32_t max() { return MIN_CALL_BODY_SZ; };
+ unsigned max() { return MIN_CALL_BODY_SZ; };
};
//-------------------------------------------------------------------------
static THREAD_LOCAL uint8_t pdu_buf[65536];
static THREAD_LOCAL StreamBuffer str_buf;
-uint32_t StreamSplitter::max()
-{ return 16384; } // FIXIT-H make default configurable
+unsigned StreamSplitter::max()
+{ return 16384; } // subclasses should override this
const StreamBuffer* StreamSplitter::reassemble(
Flow*, unsigned, unsigned offset, const uint8_t* p,
public:
virtual ~StreamSplitter() { };
- enum Status // FIXIT-H move inside StreamSplitter
+ enum Status
{
ABORT, // non-paf operation
START, // internal use only
);
virtual bool is_paf() { return false; };
- virtual uint32_t max();
+ virtual unsigned max();
virtual void reset() { };
virtual void update() { };
StreamSplitter(bool b) { c2s = b; };
private:
+ static unsigned s_max;
bool c2s;
};
{ "overlap_limit", Parameter::PT_INT, "0:255", "0",
"maximum number of allowed overlapping segments per session" },
- { "paf_max", Parameter::PT_INT, "1460:63780", "16384",
+ { "max_pdu", Parameter::PT_INT, "1460:63780", "16384",
"maximum reassembled PDU size" },
{ "policy", Parameter::PT_ENUM, policies, "linux",
else if ( v.is("max_window") )
config->max_window = v.get_long();
- else if ( v.is("paf_max") )
+ else if ( v.is("max_pdu") )
config->paf_max = v.get_long();
else if ( v.is("policy") )