diff options
author | bmeeks8 <bmeeks8@bellsouth.net> | 2014-09-08 21:11:44 -0400 |
---|---|---|
committer | bmeeks8 <bmeeks8@bellsouth.net> | 2014-09-08 21:11:44 -0400 |
commit | 6d1e6c31c7fcd7bb5d5dd48ff115ba8b09849164 (patch) | |
tree | ff008381ff4e58a7755728fd1fd48cf9ff60a7f2 /config/suricata/suricata_post_install.php | |
parent | 42d7efbec7932f35f99e6b35a2d191f959b4ac6a (diff) | |
download | pfsense-packages-6d1e6c31c7fcd7bb5d5dd48ff115ba8b09849164.tar.gz pfsense-packages-6d1e6c31c7fcd7bb5d5dd48ff115ba8b09849164.tar.bz2 pfsense-packages-6d1e6c31c7fcd7bb5d5dd48ff115ba8b09849164.zip |
Fix any duplicate UUIDs and 'dns-events.rules' entries in config.
Diffstat (limited to 'config/suricata/suricata_post_install.php')
-rw-r--r-- | config/suricata/suricata_post_install.php | 39 |
1 files changed, 39 insertions, 0 deletions
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'); |