Merge in SNORT/snort3 from ~MMATIRKO/snort3:toggle_map to master
Squashed commit of the following:
commit
63701bbedc562453be74a1c0323f3038cbaa821f
Author: Michael Matirko <mmatirko@cisco.com>
Date: Fri Feb 14 16:13:29 2025 -0500
main: allow toggling generation of instance_map output
chroot_dir.clear();
}
+void SnortConfig::set_create_instance_file(bool enabled)
+{
+ if (enabled)
+ run_flags |= RUN_FLAG__CREATE_INST_FILE;
+ else
+ run_flags &= ~RUN_FLAG__CREATE_INST_FILE;
+}
+
void SnortConfig::set_create_pid_file(bool enabled)
{
if (enabled)
RUN_FLAG__TEST_FEATURES = 0x00400000,
RUN_FLAG__GEN_DUMP_CONFIG = 0x00800000,
+ RUN_FLAG__CREATE_INST_FILE = 0x01000000,
+
#ifdef SHELL
- RUN_FLAG__SHELL = 0x01000000,
+ RUN_FLAG__SHELL = 0x02000000,
#endif
};
void set_alert_mode(const char*);
void set_chroot_dir(const char*);
void set_create_pid_file(bool);
+ void set_create_instance_file(bool);
void set_pid_filename(const char*);
void set_max_procs(uint8_t);
void set_daemon(bool);
bool gen_dump_config() const
{ return run_flags & RUN_FLAG__GEN_DUMP_CONFIG; }
+ bool create_inst_file() const
+ { return run_flags & RUN_FLAG__CREATE_INST_FILE; }
+
// other stuff
uint8_t min_ttl() const
{ return get_network_policy()->min_ttl; }
"<file> to create unix socket" },
#endif
+ { "--create-instance-file", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "create instance mappings file for this Snort process at startup" },
+
{ "--create-pidfile", Parameter::PT_STRING, "(optional)", nullptr,
"create PID file, even when not in Daemon mode" },
else if ( is(v, "--max-procs") )
sc->set_max_procs(v.get_uint8());
+ else if ( is(v, "--create-instance-file") )
+ sc->set_create_instance_file(true);
+
else if ( is(v, "--daq") )
module_config = sc->daq_config->add_module_config(v.get_string());
void populate_instance_maps()
{
+ const SnortConfig* sc = SnortConfig::get_conf();
+ if (!sc->create_inst_file())
+ return;
+
std::string path;
get_instance_file(path, INST_MAP_NAME);
void invalidate_instance_maps()
{
+ const SnortConfig* sc = SnortConfig::get_conf();
+ if (!sc->create_inst_file())
+ return;
+
std::string path;
get_instance_file(path, INST_MAP_NAME);