diff options
author | bmeeks8 <bmeeks8@bellsouth.net> | 2014-04-02 15:20:35 -0400 |
---|---|---|
committer | Ermal <ermal.luci@gmail.com> | 2014-04-08 08:47:26 +0000 |
commit | 15f1cf3eef2c09b69e029a6dda9694634dc44774 (patch) | |
tree | b8f3eaf72b0e14fedadedf04fd68f99eea7ff609 /config/snort | |
parent | 1139cfef3a327fb1160300f05e8515fd7b7a4574 (diff) | |
download | pfsense-packages-15f1cf3eef2c09b69e029a6dda9694634dc44774.tar.gz pfsense-packages-15f1cf3eef2c09b69e029a6dda9694634dc44774.tar.bz2 pfsense-packages-15f1cf3eef2c09b69e029a6dda9694634dc44774.zip |
Add code to migrate old Barnyard2 MySQL DB params to new format.
Diffstat (limited to 'config/snort')
-rw-r--r-- | config/snort/snort_migrate_config.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/config/snort/snort_migrate_config.php b/config/snort/snort_migrate_config.php index 218237ab..d7a20726 100644 --- a/config/snort/snort_migrate_config.php +++ b/config/snort/snort_migrate_config.php @@ -322,6 +322,42 @@ foreach ($rule as &$r) { } } + // Migrate any Barnyard2 settings to the new advanced fields. + // Parse the old DB connect string and find the "host", "user", + // "dbname" and "password" values and save them in the new + // MySQL field names in the config file. + if (!empty($pconfig['barnyard_mysql'])) { + if (preg_match_all('/(dbname|host|user|password)\s*\=\s*([^\s]*)/i', $pconfig['barnyard_mysql'], $matches)) { + foreach ($matches[1] as $k => $p) { + if (strcasecmp($p, 'dbname') == 0) + $pconfig['barnyard_dbname'] = $matches[2][$k]; + elseif (strcasecmp($p, 'host') == 0) + $pconfig['barnyard_dbhost'] = $matches[2][$k]; + elseif (strcasecmp($p, 'user') == 0) + $pconfig['barnyard_dbuser'] = $matches[2][$k]; + elseif (strcasecmp($p, 'password') == 0) + $pconfig['barnyard_dbpwd'] = base64_encode($matches[2][$k]); + } + $pconfig['barnyard_mysql_enable'] = 'on'; + $pconfig['barnyard_enable'] = 'on'; + unset($pconfig['barnyard_mysql']); + } + // Since Barnyard2 was enabled, configure the new archived log settings + $pconfig['u2_archived_log_retention'] = '168'; + $pconfig['barnyard_archive_enable'] = 'on'; + $pconfig['unified2_log_limit'] = '32'; + $updated_cfg = true; + } + + // This setting is deprecated and replaced + // by 'barnyard_enable' since any Barnyard2 + // chaining requires unified2 logging. + if (isset($pconfig['snortunifiedlog'])) { + unset($pconfig['snortunifiedlog']); + $pconfig['barnyard_enable'] = 'on'; + $updated_cfg = true; + } + // Save the new configuration data into the $config array pointer $r = $pconfig; } @@ -330,7 +366,7 @@ unset($r); // Write out the new configuration to disk if we changed anything if ($updated_cfg) { - $config['installedpackages']['snortglobal']['snort_config_ver'] = "3.0.4"; + $config['installedpackages']['snortglobal']['snort_config_ver'] = "3.0.5"; log_error("[Snort] Saving configuration settings in new format..."); write_config(); log_error("[Snort] Settings successfully migrated to new configuration format..."); |