From 69e99bed09652ef93607cc353cafcc99d7e54b2e Mon Sep 17 00:00:00 2001 From: bmeeks8 Date: Wed, 17 Sep 2014 15:20:53 -0400 Subject: Rename service entry when moving Snort/BY2 to another interface. --- config/snort/snort_interfaces_edit.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'config/snort') diff --git a/config/snort/snort_interfaces_edit.php b/config/snort/snort_interfaces_edit.php index aff9b4f7..98e05d82 100755 --- a/config/snort/snort_interfaces_edit.php +++ b/config/snort/snort_interfaces_edit.php @@ -32,7 +32,7 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); -global $g, $rebuild_rules; +global $g, $config, $rebuild_rules; $snortdir = SNORTDIR; $snortlogdir = SNORTLOGDIR; @@ -230,6 +230,19 @@ if ($_POST["save"] && !$input_errors) { } else $snort_start = false; + // Need to rename the service entries when moving instance to another interface + foreach ($config['installedpackages']['service'] as &$service) { + if (isset($service['uuid']) && $service['uuid'] == $a_rule[$id]['uuid'] && + $service['name'] == "snort_" . strtolower(convert_friendly_interface_to_friendly_descr($a_rule[$id]['interface']))) { + $service['name'] = "snort_" . strtolower(convert_friendly_interface_to_friendly_descr($natent['interface'])); + $service['description'] = "Snort IDS/IPS - " . convert_friendly_interface_to_friendly_descr($natent['interface']); + } + if (isset($service['uuid']) && $service['uuid'] == $a_rule[$id]['uuid'] && + $service['name'] == "barnyard2_" . strtolower(convert_friendly_interface_to_friendly_descr($a_rule[$id]['interface']))) { + $service['name'] = "barnyard2_" . strtolower(convert_friendly_interface_to_friendly_descr($natent['interface'])); + $service['description'] = "Barnyard2 Logging - " . convert_friendly_interface_to_friendly_descr($natent['interface']); + } + } @rename("{$snortlogdir}/snort_{$oif_real}{$a_rule[$id]['uuid']}", "{$snortlogdir}/snort_{$if_real}{$a_rule[$id]['uuid']}"); conf_mount_rw(); @rename("{$snortdir}/snort_{$a_rule[$id]['uuid']}_{$oif_real}", "{$snortdir}/snort_{$a_rule[$id]['uuid']}_{$if_real}"); -- cgit v1.2.3