From 6d1e6c31c7fcd7bb5d5dd48ff115ba8b09849164 Mon Sep 17 00:00:00 2001 From: bmeeks8 Date: Mon, 8 Sep 2014 21:11:44 -0400 Subject: Fix any duplicate UUIDs and 'dns-events.rules' entries in config. --- config/suricata/suricata_post_install.php | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'config/suricata/suricata_post_install.php') diff --git a/config/suricata/suricata_post_install.php b/config/suricata/suricata_post_install.php index 7c8d03a5..55a43f35 100644 --- a/config/suricata/suricata_post_install.php +++ b/config/suricata/suricata_post_install.php @@ -116,6 +116,45 @@ safe_mkdir(IPREP_PATH); if ($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] == 'on') { log_error(gettext("[Suricata] Saved settings detected... rebuilding installation with saved settings...")); update_status(gettext("Saved settings detected...")); + + /****************************************************************/ + /* Do test and fix for duplicate UUIDs if this install was */ + /* impacted by the DUP (clone) bug that generated a duplicate */ + /* UUID for the cloned interface. Also fix any duplicate */ + /* entries in ['rulesets'] for "dns-events.rules". */ + /****************************************************************/ + if (count($config['installedpackages']['suricata']['rule']) > 0) { + $uuids = array(); + $suriconf = &$config['installedpackages']['suricata']['rule']; + foreach ($suriconf as &$suricatacfg) { + // Remove any duplicate ruleset names from earlier bug + $rulesets = explode("||", $suricatacfg['rulesets']); + $suricatacfg['rulesets'] = implode("||", array_keys(array_flip($rulesets))); + + // Now check for and fix a duplicate UUID + $if_real = get_real_interface($suricatacfg['interface']); + if (!isset($uuids[$suricatacfg['uuid']])) { + $uuids[$suricatacfg['uuid']] = $if_real; + continue; + } + else { + // Found a duplicate UUID, so generate a + // new one for the affected interface. + $old_uuid = $suricatacfg['uuid']; + $new_uuid = suricata_generate_id(); + exec("mv -f {$suricatalogdir}suricata_{$if_real}" . $old_uuid . " {$suricatalogdir}suricata_{$if_real}" . $new_uuid); + $suricatacfg['uuid'] = $new_uuid; + write_config("Suricata pkg: updated UUID for interface " . convert_friendly_interface_to_friendly_descr($suricatacfg['interface']) . "."); + $uuids[$new_uuid] = $if_real; + log_error(gettext("[Suricata] updated UUID for interface " . convert_friendly_interface_to_friendly_descr($suricatacfg['interface']) . " from {$old_uuid} to {$new_uuid}.")); + } + } + unset($uuids, $rulesets); + } + /****************************************************************/ + /* End of duplicate UUID and "dns-events.rules" bug fix. */ + /****************************************************************/ + /* Do one-time settings migration for new version configuration */ update_output_window(gettext("Please wait... migrating settings to new configuration...")); include('/usr/local/pkg/suricata/suricata_migrate_config.php'); -- cgit v1.2.3 From c13c641f7ae95d18df8e0bcdfaa67af2d1c2deb2 Mon Sep 17 00:00:00 2001 From: bmeeks8 Date: Mon, 8 Sep 2014 22:56:52 -0400 Subject: Move call to write_config() so as not to invalidate the loop iterator. --- config/suricata/suricata_post_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/suricata/suricata_post_install.php') diff --git a/config/suricata/suricata_post_install.php b/config/suricata/suricata_post_install.php index 55a43f35..1d338a55 100644 --- a/config/suricata/suricata_post_install.php +++ b/config/suricata/suricata_post_install.php @@ -144,11 +144,11 @@ if ($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] = $new_uuid = suricata_generate_id(); exec("mv -f {$suricatalogdir}suricata_{$if_real}" . $old_uuid . " {$suricatalogdir}suricata_{$if_real}" . $new_uuid); $suricatacfg['uuid'] = $new_uuid; - write_config("Suricata pkg: updated UUID for interface " . convert_friendly_interface_to_friendly_descr($suricatacfg['interface']) . "."); $uuids[$new_uuid] = $if_real; log_error(gettext("[Suricata] updated UUID for interface " . convert_friendly_interface_to_friendly_descr($suricatacfg['interface']) . " from {$old_uuid} to {$new_uuid}.")); } } + write_config("Suricata pkg: updated interface UUIDs to eliminated duplicates."); unset($uuids, $rulesets); } /****************************************************************/ -- cgit v1.2.3 From 101c875be3cbc8158b787eb480a0077135f70d35 Mon Sep 17 00:00:00 2001 From: bmeeks8 Date: Mon, 8 Sep 2014 23:28:54 -0400 Subject: Bump Suricata GUI package version to 2.0.3 v2.0.2 --- config/suricata/suricata_post_install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config/suricata/suricata_post_install.php') diff --git a/config/suricata/suricata_post_install.php b/config/suricata/suricata_post_install.php index 1d338a55..47e42c38 100644 --- a/config/suricata/suricata_post_install.php +++ b/config/suricata/suricata_post_install.php @@ -148,7 +148,7 @@ if ($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] = log_error(gettext("[Suricata] updated UUID for interface " . convert_friendly_interface_to_friendly_descr($suricatacfg['interface']) . " from {$old_uuid} to {$new_uuid}.")); } } - write_config("Suricata pkg: updated interface UUIDs to eliminated duplicates."); + write_config("Suricata pkg: updated interface UUIDs to eliminate duplicates."); unset($uuids, $rulesets); } /****************************************************************/ @@ -237,7 +237,7 @@ if (empty($config['installedpackages']['suricata']['config'][0]['forcekeepsettin conf_mount_ro(); // Update Suricata package version in configuration -$config['installedpackages']['suricata']['config'][0]['suricata_config_ver'] = "2.0"; +$config['installedpackages']['suricata']['config'][0]['suricata_config_ver'] = "2.0.2"; write_config("Suricata pkg: updated GUI package version number."); // Done with post-install, so clear flag -- cgit v1.2.3 From 942f82201a14aebc97f872aeddae893b9a1e0a55 Mon Sep 17 00:00:00 2001 From: bmeeks8 Date: Tue, 9 Sep 2014 12:00:20 -0400 Subject: Use rename() instead of shell call for renaming directories. --- config/suricata/suricata_post_install.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'config/suricata/suricata_post_install.php') diff --git a/config/suricata/suricata_post_install.php b/config/suricata/suricata_post_install.php index 47e42c38..42f72eca 100644 --- a/config/suricata/suricata_post_install.php +++ b/config/suricata/suricata_post_install.php @@ -142,7 +142,8 @@ if ($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] = // new one for the affected interface. $old_uuid = $suricatacfg['uuid']; $new_uuid = suricata_generate_id(); - exec("mv -f {$suricatalogdir}suricata_{$if_real}" . $old_uuid . " {$suricatalogdir}suricata_{$if_real}" . $new_uuid); + if (file_exists("{$suricatalogdir}suricata_{$if_real}{$old_uuid}/")) + @rename("{$suricatalogdir}suricata_{$if_real}{$old_uuid}/", "{$suricatalogdir}suricata_{$if_real}{$new_uuid}/"); $suricatacfg['uuid'] = $new_uuid; $uuids[$new_uuid] = $if_real; log_error(gettext("[Suricata] updated UUID for interface " . convert_friendly_interface_to_friendly_descr($suricatacfg['interface']) . " from {$old_uuid} to {$new_uuid}.")); -- cgit v1.2.3