"LAN"); for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) $iflist['opt' . $i] = "opt{$i}"; $whitelist = fopen("/var/db/whitelist","w"); if(!$whitelist) { log_error("Cannot open whitelist for /var/db/writing."); exit; } foreach($iflist as $if) { /* XXX: write out if subnet */ } fclose($whitelist); foreach($_POST['interface_array'] as $iface) { $if = convert_friendly_interface_to_real_interface_name($iface); if($if) { $ifaces_final .= " -i " . $if; $first = 1; } } $start = "snort -c /usr/local/etc/snort/snort.conf -l /var/log/snort " . $ifaces_final . " -D"; $start .= ";snort2c -s -w /var/db/whitelist -a /var/log/snort/alert"; write_rcfile(array( "file" => "snort.sh", "start" => $start, "stop" => "/usr/bin/killall snort; killall snort2c" ) ); /* write out snort.conf */ $snort_conf = generate_snort_conf(); $conf = fopen("/usr/local/etc/snort/snort.conf","w"); if(!$conf) { log_error("Could not open /usr/local/etc/snort/snort.conf for writing."); exit; } fwrite($conf, $snort_conf); fclose($conf); start_service("snort"); } function generate_snort_conf() { global $config, $g; $ssh_port = ""; $home_net = ""; /* XXX: generate rule section */ $selected_rules_sections = ""; $snort_conf = <<