コード例 #1
0
function add_base_packages_menu_items()
{
    global $g, $config;
    $base_packages = split($g['base_packages'], ",");
    $modified_config = false;
    foreach ($base_packages as $bp) {
        $basepkg_path = "/usr/local/pkg/";
        if (file_exists($basepkg_path . $configfile)) {
            $pkg_config = parse_xml_config_pkg($basepkg_path . $bp, "packagegui");
            if ($pkg_config['menu'] != "") {
                if (is_array($pkg_config['menu'])) {
                    foreach ($pkg_config['menu'] as $menu) {
                        if (is_array($config['installedpackages']['menu'])) {
                            foreach ($config['installedpackages']['menu'] as $amenu) {
                                if ($amenu['name'] == $menu['name']) {
                                    continue;
                                }
                            }
                        }
                        $config['installedpackages']['menu'][] = $menu;
                        $modified_config = true;
                    }
                }
                $static_output .= "done.\n";
                update_output_window($static_output);
            }
        }
    }
    if ($modified_config) {
        write_confg("Restored base_package menus after configuration restore.");
        $config = parse_config(true);
    }
}
コード例 #2
0
function read_body_firmware($ch, $string)
{
    global $fout, $file_size, $downloaded, $counter, $version, $latest_version, $current_installed_pfsense_version;
    $length = strlen($string);
    $downloaded += intval($length);
    $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
    $downloadProgress = 100 - $downloadProgress;
    $a = $file_size;
    $b = $downloaded;
    $c = $downloadProgress;
    $text = "  Snort download in progress\\n";
    $text .= "----------------------------------------------------\\n";
    $text .= "  Downloaded      : {$b}\\n";
    $text .= "----------------------------------------------------\\n";
    $counter++;
    if ($counter > 150) {
        update_output_window($text);
        update_progress_bar($downloadProgress);
        flush();
        $counter = 0;
    }
    conf_mount_rw();
    fwrite($fout, $string);
    conf_mount_ro();
    return $length;
}
コード例 #3
0
function read_body_firmware($ch, $string)
{
    global $g, $fout, $file_size, $downloaded, $counter, $version, $latest_version;
    $length = strlen($string);
    $downloaded += intval($length);
    $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
    $downloadProgress = 100 - $downloadProgress;
    $a = $file_size;
    $b = $downloaded;
    $c = $downloadProgress;
    $text = "  " . gettext("Auto Update Download Status") . "\\n";
    $text .= "----------------------------------------------------\\n";
    $text .= "  " . gettext("Current Version") . " : {$g['product_version']}\\n";
    $text .= "  " . gettext("Latest Version") . "  : {$latest_version}\\n";
    $text .= "  " . gettext("File size") . "       : {$a}\\n";
    $text .= "  " . gettext("Downloaded") . "      : {$b}\\n";
    $text .= "  " . gettext("Percent") . "         : {$c}%\\n";
    $text .= "----------------------------------------------------\\n";
    $counter++;
    if ($counter > 150) {
        update_output_window($text);
        update_progress_bar($downloadProgress);
        $counter = 0;
    }
    fwrite($fout, $string);
    return $length;
}
コード例 #4
0
ファイル: diag_backup.php プロジェクト: jdillard/pfsense
function add_base_packages_menu_items()
{
    global $g, $config;
    $base_packages = explode(",", $g['base_packages']);
    $modified_config = false;
    foreach ($base_packages as $bp) {
        $basepkg_path = "/usr/local/pkg/{$bp}";
        $tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION);
        if ($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) {
            $pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui");
            if ($pkg_config['menu'] != "") {
                if (is_array($pkg_config['menu'])) {
                    foreach ($pkg_config['menu'] as $menu) {
                        if (is_array($config['installedpackages']['menu'])) {
                            foreach ($config['installedpackages']['menu'] as $amenu) {
                                if ($amenu['name'] == $menu['name']) {
                                    continue;
                                }
                            }
                        }
                        $config['installedpackages']['menu'][] = $menu;
                        $modified_config = true;
                    }
                }
                $static_output .= "done.\n";
                update_output_window($static_output);
            }
        }
    }
    if ($modified_config) {
        write_config(gettext("Restored base_package menus after configuration restore."));
        $config = parse_config(true);
    }
}
コード例 #5
0
    }
    $rebuild_rules = false;
    if ($pkg_interface != "console") {
        $static_output .= gettext("Finished rebuilding Suricata configuration from saved settings.\n");
        update_output_window($static_output);
    }
    log_error(gettext("[Suricata] Finished rebuilding installation from saved settings..."));
    // Only try to start Suricata if not in reboot
    if (!$g['booting']) {
        if ($pkg_interface != "console") {
            update_status(gettext("Starting Suricata using rebuilt configuration..."));
            $static_output .= gettext("Starting Suricata using the rebuilt configuration...");
            update_output_window($static_output);
            mwexec_bg("{$rcdir}suricata.sh start");
            $static_output .= gettext(" done.\n");
            update_output_window($static_output);
        } else {
            mwexec_bg("{$rcdir}suricata.sh start");
        }
    }
}
// If this is first install and "forcekeepsettings" is empty,
// then default it to 'on'.
if (empty($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'])) {
    $config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] = 'on';
}
// Finished with file system mods, so remount it read-only
conf_mount_ro();
// Update Suricata package version in configuration
$config['installedpackages']['suricata']['config'][0]['suricata_config_ver'] = $config['installedpackages']['package'][get_pkg_id("suricata")]['version'];
write_config("Suricata pkg v{$config['installedpackages']['package'][get_pkg_id("suricata")]['version']}: post-install configuration saved.");
コード例 #6
0
function suricata_fetch_new_rules($file_url, $file_dst, $file_md5, $desc = "")
{
    /**********************************************************/
    /* This function downloads the passed rules file and      */
    /* compares its computed md5 hash to the passed md5 hash  */
    /* to verify the file's integrity.                        */
    /*                                                        */
    /* On Entry: $file_url = URL of rules file                */
    /*           $file_dst = Temp destination to store the    */
    /*                       downloaded rules file            */
    /*           $file_md5 = Expected md5 hash for the new    */
    /*                       downloaded rules file            */
    /*           $desc     = Short text string for use in     */
    /*                       log messages                     */
    /*                                                        */
    /*  Returns: TRUE if download was successful.             */
    /*           FALSE if download was not successful.        */
    /**********************************************************/
    global $pkg_interface, $last_curl_error, $update_errors;
    $suricatadir = SURICATADIR;
    $filename = basename($file_dst);
    if ($pkg_interface != "console") {
        update_status(gettext("There is a new set of {$desc} posted. Downloading..."));
    }
    log_error(gettext("[Suricata] There is a new set of {$desc} posted. Downloading {$filename}..."));
    error_log(gettext("\tThere is a new set of {$desc} posted.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
    error_log(gettext("\tDownloading file '{$filename}'...\n"), 3, SURICATA_RULES_UPD_LOGFILE);
    $rc = suricata_download_file_url($file_url, $file_dst);
    // See if the download from the URL was successful
    if ($rc === true) {
        if ($pkg_interface != "console") {
            update_status(gettext("Done downloading {$desc} file."));
        }
        log_error("[Suricata] {$desc} file update downloaded successfully");
        error_log(gettext("\tDone downloading rules file.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
        // Test integrity of the rules file.  Turn off update if file has wrong md5 hash
        if ($file_md5 != trim(md5_file($file_dst))) {
            if ($pkg_interface != "console") {
                update_output_window(gettext("{$desc} file MD5 checksum failed..."));
            }
            log_error(gettext("[Suricata] {$desc} file download failed.  Bad MD5 checksum..."));
            log_error(gettext("[Suricata] Downloaded File MD5: " . md5_file($file_dst)));
            log_error(gettext("[Suricata] Expected File MD5: {$file_md5}"));
            error_log(gettext("\t{$desc} file download failed.  Bad MD5 checksum.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
            error_log(gettext("\tDownloaded {$desc} file MD5: " . md5_file($file_dst) . "\n"), 3, SURICATA_RULES_UPD_LOGFILE);
            error_log(gettext("\tExpected {$desc} file MD5: {$file_md5}\n"), 3, SURICATA_RULES_UPD_LOGFILE);
            error_log(gettext("\t{$desc} file download failed.  {$desc} will not be updated.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
            $update_errors = true;
            return false;
        }
        return true;
    } else {
        if ($pkg_interface != "console") {
            update_output_window(gettext("{$desc} file download failed..."));
        }
        log_error(gettext("[Suricata] {$desc} file download failed... server returned error '{$rc}'..."));
        error_log(gettext("\t{$desc} file download failed.  Server returned error {$rc}.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
        if ($pkg_interface == "console") {
            error_log(gettext("\tThe error text was: {$last_curl_error}\n"), 3, SURICATA_RULES_UPD_LOGFILE);
        }
        error_log(gettext("\t{$desc} will not be updated.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
        $update_errors = true;
        return false;
    }
}
コード例 #7
0
    echo "</html>";
    exit;
}
echo "\n<script type=\"text/javascript\">\n";
echo "//<![CDATA[\n";
echo "jQuery('#invokeupgrade').css('visibility','visible');\n";
echo "//]]>\n";
echo "</script>\n";
echo "\n<script type=\"text/javascript\">\n";
echo "//<![CDATA[\n";
echo "jQuery('#backupdiv').css('visibility','visible');\n";
echo "//]]>\n";
echo "</script>\n";
$txt = gettext("A new version is now available") . "\\n\\n";
$txt .= gettext("Current version") . ": " . $g['product_version'] . "\\n";
if ($g['platform'] == "nanobsd") {
    $txt .= "  " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "\\n";
}
$txt .= "       " . gettext("Built On") . ": " . $current_installed_buildtime . "\\n";
$txt .= "    " . gettext("New version") . ": " . htmlspecialchars($remote_version, ENT_QUOTES | ENT_HTML401) . "\\n\\n";
$txt .= "  " . gettext("Update source") . ": " . $updater_url . "\\n";
update_output_window($txt);
?>
</p>
</form>
<?php 
include "fend.inc";
?>
</body>
</html>
コード例 #8
0
function oinkmaster_run($id, $if_real, $iface_uuid)
{
    global $config, $g, $snortdir_wan, $snortdir, $snort_md5_check_ok, $emerg_md5_check_ok, $pfsense_md5_check_ok;
    if ($snort_md5_check_ok != 'on' || $emerg_md5_check_ok != 'on' || $pfsense_md5_check_ok != 'on') {
        if (empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on']) && empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off'])) {
            update_status(gettext("Your first set of rules are being copied..."));
            update_output_window(gettext("May take a while..."));
            exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}/rules/");
            exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
        } else {
            update_status(gettext("Your enable and disable changes are being applied to your fresh set of rules..."));
            update_output_window(gettext("May take a while..."));
            exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}/rules/");
            exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}");
            /*  might have to add a sleep for 3sec for flash drives or old drives */
            exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/oinkmaster_{$iface_uuid}_{$if_real}.conf -o /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules > /usr/local/etc/snort/oinkmaster_{$iface_uuid}_{$if_real}.log");
        }
    }
}
コード例 #9
0
                            }
                        }
                    }
                }
            }
            if ($changed == true) {
                @file_put_contents($file, implode("\n", $splitcontents));
            }
        }
    }
}
if ($snortdownload == 'on' || $emergingthreats == 'on') {
    /* You are Not Up to date, always stop snort when updating rules for low end machines */
    /* Start the proccess for every interface rule */
    if (is_array($config['installedpackages']['snortglobal']['rule'])) {
        foreach ($config['installedpackages']['snortglobal']['rule'] as $id => $value) {
            $if_real = snort_get_real_interface($value['interface']);
            /* make oinkmaster.conf for each interface rule */
            snort_apply_customizations($value, $if_real);
        }
    }
    exec("/bin/sh /usr/local/etc/rc.d/snort.sh restart");
    sleep(10);
    if (!is_process_running("snort")) {
        exec("/bin/sh /usr/local/etc/rc.d/snort.sh start");
    }
    update_output_window(gettext("Snort has restarted with your new set of rules..."));
    log_error("Snort has restarted with your new set of rules...");
}
update_status(gettext("The Rules update finished..."));
conf_mount_ro();
コード例 #10
0
    snort_rules_up_install_cron($config['installedpackages']['snortglobal']['autorulesupdate7'] != "never_up" ? true : false);
    /* Restore the last Snort Dashboard Widget setting if none is set */
    if (!empty($config['installedpackages']['snortglobal']['dashboard_widget']) && stristr($config['widgets']['sequence'], "snort_alerts-container") === FALSE) {
        $config['widgets']['sequence'] .= "," . $config['installedpackages']['snortglobal']['dashboard_widget'];
    }
    $rebuild_rules = false;
    if ($pkg_interface != "console") {
        update_output_window(gettext("Finished rebuilding Snort configuration files..."));
    }
    log_error(gettext("[Snort] Finished rebuilding installation from saved settings..."));
    /* Only try to start Snort if not in reboot */
    if (!$g['booting']) {
        if ($pkg_interface != "console") {
            update_status(gettext("Starting Snort using rebuilt configuration..."));
            mwexec_bg("{$rcdir}snort.sh start");
            update_output_window(gettext("Snort is starting as a background task using the rebuilt configuration..."));
        } else {
            mwexec_bg("{$rcdir}snort.sh start");
        }
    }
}
/* We're finished with conf partition mods, return to read-only */
conf_mount_ro();
/* If an existing Snort Dashboard Widget container is not found, */
/* then insert our default Widget Dashboard container.           */
if (stristr($config['widgets']['sequence'], "snort_alerts-container") === FALSE) {
    $config['widgets']['sequence'] .= ",{$snort_widget_container}";
}
/* Update Snort package version in configuration */
$config['installedpackages']['snortglobal']['snort_config_ver'] = "3.2.6";
write_config("Snort pkg v3.2.6: post-install configuration saved.");
コード例 #11
0
                update_output_window(gettext("Something is wrong on the request."));
            } else {
                if (file_exists("/tmp/pkg_mgr_{$pkgname}.log")) {
                    update_output_window(@file_get_contents("/tmp/pkg_mgr_{$pkgname}.log"));
                } else {
                    update_output_window(gettext("Log was not retrievable."));
                }
            }
            break;
        case 'installedinfo':
            if (file_exists("/tmp/{$pkgname}.info")) {
                $status = @file_get_contents("/tmp/{$pkgname}.info");
                update_status("{$pkgname} " . gettext("installation completed."));
                update_output_window($status);
            } else {
                update_output_window(sprintf(gettext("Could not find %s."), $pkgname));
            }
            break;
        default:
            break;
    }
} else {
    if ($_POST) {
        $pkgid = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_POST['id'], ENT_QUOTES | ENT_HTML401));
        /* All other cases make changes, so mount rw fs */
        conf_mount_rw();
        /* Write out configuration to create a backup prior to pkg install. */
        write_config(gettext("Creating restore point before package installation."));
        $progbar = true;
        switch ($_POST['mode']) {
            case 'delete':
コード例 #12
0
function read_body($ch, $string)
{
    global $fout, $file_size, $downloaded, $counter, $version, $latest_version, $current_installed_pfsense_version;
    $length = strlen($string);
    $downloaded += intval($length);
    $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
    $downloadProgress = 100 - $downloadProgress;
    $a = $file_size;
    $b = $downloaded;
    $c = $downloadProgress;
    $text = "  Auto Update Download Status\\n";
    $text .= "---------------------------------\\n";
    $text .= "  Latest Version  : {$latest_version}\\n";
    $text .= "  Current Version : {$current_installed_pfsense_version}\\n";
    $text .= "  File size       : {$a}\\n";
    $text .= "  Downloaded      : {$b}\\n";
    $text .= "  Percent         : {$c}%\\n";
    $text .= "---------------------------------\\n";
    $counter++;
    if ($counter > 150) {
        update_output_window($text);
        update_progress_bar($downloadProgress);
        $counter = 0;
    }
    fwrite($fout, $string);
    return $length;
}
コード例 #13
0
    }
    if (!empty($config['installedpackages']['suricata']['config'][0]['dashboard_widget_rows']) && !empty($config['widgets'])) {
        if (empty($config['widgets']['widget_suricata_display_lines'])) {
            $config['widgets']['widget_suricata_display_lines'] = $config['installedpackages']['suricata']['config'][0]['dashboard_widget_rows'];
        }
    }
    $rebuild_rules = false;
    update_output_window(gettext("Finished rebuilding Suricata configuration files..."));
    log_error(gettext("[Suricata] Finished rebuilding installation from saved settings..."));
    // Only try to start Suricata if not in reboot
    if (!$g['booting']) {
        update_status(gettext("Starting Suricata using rebuilt configuration..."));
        update_output_window(gettext("Please wait... while Suricata is started..."));
        log_error(gettext("[Suricata] Starting Suricata using rebuilt configuration..."));
        mwexec_bg("{$rcdir}suricata.sh start");
        update_output_window(gettext("Suricata has been started using the rebuilt configuration..."));
    }
}
// If this is first install and "forcekeepsettings" is empty,
// then default it to 'on'.
if (empty($config['installedpackages']['suricata']['config'][0]['forcekeepsettings'])) {
    $config['installedpackages']['suricata']['config'][0]['forcekeepsettings'] = 'on';
}
// Finished with file system mods, so remount it read-only
conf_mount_ro();
// Update Suricata package version in configuration
$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
unset($g['suricata_postinstall']);
log_error(gettext("[Suricata] Package post-installation tasks completed..."));
コード例 #14
0
}
if (!$latest_version) {
    if (isset($curcfg['alturl']['enable'])) {
        update_output_window("Could not contact custom update server.");
    } else {
        update_output_window("Could not contact {$g['product_name']} update server {$updater_url}.");
    }
} else {
    if ($needs_system_upgrade) {
        echo "\n<script language=\"JavaScript\">\$('invokeupgrade').style.visibility = 'visible';</script>";
        $txt = "A new version is now available \\n\\n";
        $txt .= "New version:     {$latest_version}\\n";
        $txt .= "Current version: {$current_installed_pfsense_version}\\n";
        $txt .= "Update source:   {$updater_url}\\n";
        update_output_window($txt);
    } else {
        update_output_window("You are on the latest version.");
    }
}
?>

</form>
<?php 
include "fend.inc";
?>
</body>
</html>


</body>
</html>
コード例 #15
0
function read_lists($log_notice = true, $uw = "")
{
    global $config, $g;
    $group_type = array();
    $dir = DANSGUARDIAN_DIR . "/etc/dansguardian/lists";
    #read dansguardian lists dirs
    $groups = array("phraselists", "blacklists", "whitelists");
    #assigns know list files
    $types = array('domains', 'urls', 'banned', 'weighted', 'exception', 'expression');
    #clean previous xml config for dansguardian lists
    foreach ($config['installedpackages'] as $key => $values) {
        if (preg_match("/dansguardian(phrase|black|white)lists/", $key)) {
            unset($config['installedpackages'][$key]);
        }
    }
    #find lists
    foreach ($groups as $group) {
        if (is_dir("{$dir}/{$group}/")) {
            #read dir content and find lists
            $lists = scandir("{$dir}/{$group}/");
            foreach ($lists as $list) {
                if (!preg_match("/^\\./", $list) && is_dir("{$dir}/{$group}/{$list}/")) {
                    $category = scandir("{$dir}/{$group}/{$list}/");
                    foreach ($category as $file) {
                        if (!preg_match("/^\\./", $file)) {
                            if (is_dir("{$dir}/{$group}/{$list}/{$file}")) {
                                $subdir = $file;
                                $subcategory = scandir("{$dir}/{$group}/{$list}/{$subdir}/");
                                foreach ($subcategory as $file) {
                                    if (!preg_match("/^\\./", $file)) {
                                        #assign list to array
                                        $type = split("_", $file);
                                        if (preg_match("/(\\w+)/", $type[0], $matches)) {
                                        }
                                        $xml_type = $matches[1];
                                        if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] == "both" && $group == "blacklists") {
                                            $config['installedpackages']['dansguardianwhitelists' . $xml_type]['config'][] = array("descr" => "{$list}_{$subdir} {$file}", "list" => "{$list}_{$subdir}", "file" => "{$dir}/{$group}/{$list}/{$subdir}/{$file}");
                                        }
                                        $config['installedpackages']['dansguardian' . $group . $xml_type]['config'][] = array("descr" => "{$list}_{$subdir} {$file}", "list" => "{$list}_{$subdir}", "file" => "{$dir}/{$group}/{$list}/{$subdir}/{$file}");
                                    }
                                }
                            } else {
                                #assign list to array
                                $type = split("_", $file);
                                if (preg_match("/(\\w+)/", $type[0], $matches)) {
                                }
                                $xml_type = $matches[1];
                                if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] == "both" && $group == "blacklists") {
                                    $config['installedpackages']['dansguardianwhitelists' . $xml_type]['config'][] = array("descr" => "{$list} {$file}", "list" => $list, "file" => "{$dir}/{$group}/{$list}/{$file}");
                                }
                                $config['installedpackages']['dansguardian' . $group . $xml_type]['config'][] = array("descr" => "{$list} {$file}", "list" => $list, "file" => "{$dir}/{$group}/{$list}/{$file}");
                            }
                        }
                    }
                }
            }
        }
    }
    conf_mount_rw();
    $files = array("site", "url");
    foreach ($files as $edit_xml) {
        $edit_file = file_get_contents("/usr/local/pkg/dansguardian_" . $edit_xml . "_acl.xml");
        if (count($config['installedpackages']['dansguardianblacklistsdomains']['config']) > 18) {
            $edit_file = preg_replace('/size.6/', 'size>20', $edit_file);
            if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] == "both") {
                $edit_file = preg_replace('/size.5/', 'size>19', $edit_file);
            }
        } else {
            $edit_file = preg_replace('/size.20/', 'size>6', $edit_file);
        }
        if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] != "both") {
            $edit_file = preg_replace('/size.19/', 'size>5', $edit_file);
        }
        file_put_contents("/usr/local/pkg/dansguardian_" . $edit_xml . "_acl.xml", $edit_file, LOCK_EX);
    }
    write_config();
    if ($log_notice == true && $uw == "") {
        file_notice("Dansguardian - Blacklist applied, check site and URL access lists for categories", "");
    } else {
        $uw .= "done\n";
        update_output_window($uw);
    }
}
コード例 #16
0
    /* Add the recurring jobs created above to crontab */
    configure_cron();
    /* Restore the last Snort Dashboard Widget setting if none is set */
    if (!empty($config['installedpackages']['snortglobal']['dashboard_widget']) && stristr($config['widgets']['sequence'], "snort_alerts-container") === FALSE) {
        $config['widgets']['sequence'] .= "," . $config['installedpackages']['snortglobal']['dashboard_widget'];
    }
    $rebuild_rules = false;
    update_output_window(gettext("Finished rebuilding Snort configuration files..."));
    log_error(gettext("[Snort] Finished rebuilding installation from saved settings..."));
    /* Only try to start Snort if not in reboot */
    if (!$g['booting']) {
        update_status(gettext("Starting Snort using rebuilt configuration..."));
        update_output_window(gettext("Please wait... while Snort is started..."));
        log_error(gettext("[Snort] Starting Snort using rebuilt configuration..."));
        mwexec_bg("{$rcdir}snort.sh start");
        update_output_window(gettext("Snort is starting using the rebuilt configuration..."));
    }
}
/* We're finished with conf partition mods, return to read-only */
conf_mount_ro();
/* If an existing Snort Dashboard Widget container is not found, */
/* then insert our default Widget Dashboard container.           */
if (stristr($config['widgets']['sequence'], "snort_alerts-container") === FALSE) {
    $config['widgets']['sequence'] .= ",{$snort_widget_container}";
}
/* Update Snort package version in configuration */
$config['installedpackages']['snortglobal']['snort_config_ver'] = "3.1.2";
write_config("Snort pkg: post-install configuration saved.");
/* Done with post-install, so clear flag */
unset($g['snort_postinstall']);
log_error(gettext("[Snort] Package post-installation tasks completed..."));