if ( !check_total )
return;
+ LogLabel("File Statistics");
LogLabel("file type stats (files)");
LogMessage(" Type Download Upload \n");
// packet passing is done by the driver/hardware. the goal then is to put as
// much initialization stuff in Snort::init() as possible and to restrict this
// function to those things that depend on DAQ startup or non-root user/group.
-//
-// FIXIT-L breaks DAQ_New()/Start() because packet threads won't be root when
-// opening iface
+
void Snort::drop_privileges()
{
- if ( SnortConfig::create_pid_file() )
- CreatePidFile(snort_main_thread_pid);
-
/* FIXIT-M X - I have no idea if the chroot functionality actually works. */
/* Drop the Chrooted Settings */
if ( !snort_conf->chroot_dir.empty() )
/* Drop privileges if requested, when initialization is done */
SetUidGid(SnortConfig::get_uid(), SnortConfig::get_gid());
+ if ( SnortConfig::create_pid_file() )
+ CreatePidFile(snort_main_thread_pid);
+
initializing = false;
privileges_dropped = true;
}
static DAQ_Mode daq_mode = DAQ_MODE_PASSIVE;
static uint32_t snap = DEFAULT_PKT_SNAPLEN;
static bool loaded = false;
+static std::mutex bpf_gate;
// specific for each thread / instance
static THREAD_LOCAL SFDAQInstance *local_instance = nullptr;
bool SFDAQInstance::set_filter(const char* bpf)
{
int err = 0;
- static std::mutex bpf_gate;
- // doesn't look like the bpf flex scanner is reentrant
- bpf_gate.lock();
+ // The BPF can be compiled either during daq_set_filter() or daq_start(),
+ // so protect the thread-unsafe BPF scanner/compiler in both places.
if (bpf and *bpf)
+ {
+ std::lock_guard<std::mutex> lock(bpf_gate);
err = daq_set_filter(daq_mod, daq_hand, bpf);
-
- bpf_gate.unlock();
+ }
if (err)
FatalError("Can't set DAQ BPF filter to '%s' (%s)\n",
bool SFDAQInstance::start()
{
- int err = daq_start(daq_mod, daq_hand);
+ int err;
+
+ // The BPF can be compiled either during daq_set_filter() or daq_start(),
+ // so protect the thread-unsafe BPF scanner/compiler in both places.
+ {
+ std::lock_guard<std::mutex> lock(bpf_gate);
+ err = daq_start(daq_mod, daq_hand);
+ }
if (err)
ErrorMessage("Can't start DAQ (%d) - %s\n", err, daq_get_error(daq_mod, daq_hand));
ponew = PortObjectNew();
if ( !ponew )
- return 0;
+ return nullptr;
/* Dup the Name */
if ( po->name )
poinew = PortObjectItemDup(poi);
if (!poinew)
{
- snort_free(ponew->name);
- snort_free(ponew);
- return 0;
+ PortObjectFree(ponew);
+ return nullptr;
}
PortObjectAddItem(ponew, poinew, NULL);
ponew = PortObjectNew();
if ( !ponew )
- return 0;
+ return nullptr;
/* Dup the Name */
if ( po->name )
poinew = PortObjectItemDup(poi);
if (!poinew)
{
- snort_free(ponew);
- return NULL;
+ PortObjectFree(ponew);
+ return nullptr;
}
PortObjectAddItem(ponew, poinew, NULL);
}
if (!poinew)
{
- snort_free(ponew);
+ PortObject2Free(ponew);
return NULL;
}
const char* exclude = "daq snort";
ModuleManager::dump_stats(snort_conf, exclude);
- LogLabel("File Statistics");
file_stats_print();
LogLabel("Summary Statistics");