$service) { if (isset($service['uuid']) && $service['uuid'] == $snort_uuid && $service['name'] == "snort_" . strtolower($a_nat[$rulei]['interface'])) { unset($pkg_serv[$key]); unlink_if_exists("{$g['varrun_path']}/snort_{$snort_uuid}.disabled"); } if (isset($service['uuid']) && $service['uuid'] == $snort_uuid && $service['name'] == "barnyard2_" . strtolower($a_nat[$rulei]['interface'])) { unset($pkg_serv[$key]); unlink_if_exists("{$g['varrun_path']}/barnyard2_{$snort_uuid}.disabled"); } } snort_stop($a_nat[$rulei], $if_real); rmdir_recursive("{$snortlogdir}/snort_{$if_real}{$snort_uuid}"); rmdir_recursive("{$snortdir}/snort_{$snort_uuid}_{$if_real}"); // Finally delete the interface's config entry entirely unset($a_nat[$rulei]); } conf_mount_ro(); /* If all the Snort interfaces are removed, then unset the interfaces config array. */ if (empty($a_nat)) unset($a_nat); write_config("Snort pkg: deleted one or more Snort interfaces."); sleep(2); sync_snort_package_config(); header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); header( 'Cache-Control: no-store, no-cache, must-revalidate' ); header( 'Cache-Control: post-check=0, pre-check=0', false ); header( 'Pragma: no-cache' ); header("Location: /snort/snort_interfaces.php"); exit; } } /* start/stop barnyard2 */ if ($_POST['bartoggle'] && is_numericint($_POST['id'])) { $snortcfg = $config['installedpackages']['snortglobal']['rule'][$_POST['id']]; $if_real = get_real_interface($snortcfg['interface']); $if_friendly = convert_friendly_interface_to_friendly_descr($snortcfg['interface']); if (!snort_is_running($snortcfg['uuid'], $if_real, 'barnyard2')) { log_error("Toggle (barnyard starting) for {$if_friendly}({$if_real})..."); sync_snort_package_config(); snort_barnyard_start($snortcfg, $if_real); unlink_if_exists("{$g['varrun_path']}/barnyard2_{$snortcfg['uuid']}.disabled"); } else { log_error("Toggle (barnyard stopping) for {$if_friendly}({$if_real})..."); touch("{$g['varrun_path']}/barnyard2_{$snortcfg['uuid']}.disabled"); snort_barnyard_stop($snortcfg, $if_real); } sleep(3); // So the GUI reports correctly } /* start/stop snort */ if ($_POST['toggle'] && is_numericint($_POST['id'])) { $snortcfg = $config['installedpackages']['snortglobal']['rule'][$_POST['id']]; $if_real = get_real_interface($snortcfg['interface']); $if_friendly = convert_friendly_interface_to_friendly_descr($snortcfg['interface']); if (snort_is_running($snortcfg['uuid'], $if_real)) { log_error("Toggle (snort stopping) for {$if_friendly}({$if_real})..."); touch("{$g['varrun_path']}/snort_{$snortcfg['uuid']}.disabled"); snort_stop($snortcfg, $if_real); } else { log_error("Toggle (snort starting) for {$if_friendly}({$if_real})..."); /* set flag to rebuild interface rules before starting Snort */ $rebuild_rules = true; sync_snort_package_config(); $rebuild_rules = false; snort_start($snortcfg, $if_real); unlink_if_exists("{$g['varrun_path']}/snort_{$snortcfg['uuid']}.disabled"); } sleep(3); // So the GUI reports correctly } $pgtitle = "Services: $snort_package_version"; include_once("head.inc"); ?>