コード例 #1
0
    if ($a_graphs[$graphid]) {
        unset($a_graphs[$graphid]);
        $a_mailreports[$id]['row'] = $a_graphs;
        write_config();
        header("Location: status_mail_report_edit.php?id={$id}");
        exit;
    }
}
$frequencies = array("daily", "weekly", "monthly");
$daysofweek = array("" => "", "0" => "sunday", "1" => "monday", "2" => "tuesday", "3" => "wednesday", "4" => "thursday", "5" => "friday", "6" => "saturday");
$dayofmonth = array("", "1", "15");
if ($_POST) {
    unset($_POST['__csrf_magic']);
    $pconfig = $_POST;
    if ($_POST['Submit'] == "Send Now") {
        mwexec_bg("/usr/local/bin/mail_reports_generate.php {$id}");
        header("Location: status_mail_report_edit.php?id={$id}");
        exit;
    }
    $friendly = "";
    // Default to midnight if unset/invalid.
    $pconfig['timeofday'] = isset($pconfig['timeofday']) ? $pconfig['timeofday'] : 0;
    $friendlytime = sprintf("%02d:00", $pconfig['timeofday']);
    $friendly = "Daily at {$friendlytime}";
    // If weekly, check for day of week
    if ($pconfig['frequency'] == "weekly") {
        $pconfig['dayofweek'] = isset($pconfig['dayofweek']) ? $pconfig['dayofweek'] : 0;
        $friendly = "Weekly, on {$daysofweek[$pconfig['dayofweek']]} at {$friendlytime}";
    } else {
        if (isset($pconfig['dayofweek'])) {
            unset($pconfig['dayofweek']);
コード例 #2
0
ファイル: installer.php プロジェクト: mtisza/pfsense
function start_installation()
{
    global $g, $fstype, $savemsg;
    if (file_exists("/tmp/install_complete")) {
        return;
    }
    $ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
    if ($ps_running) {
        return;
    }
    $fd = fopen("/tmp/installer.sh", "w");
    if (!$fd) {
        die(gettext("Could not open /tmp/installer.sh for writing"));
        exit;
    }
    fwrite($fd, "/bin/rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
    fwrite($fd, "/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh -c /usr/sbin/pc-sysinstall/examples/pfSense-install.cfg \n");
    fwrite($fd, "/bin/chmod a+rx /usr/local/bin/after_installation_routines.sh\n");
    fwrite($fd, "cd / && /usr/local/bin/after_installation_routines.sh\n");
    fwrite($fd, "/bin/mkdir /mnt/tmp\n");
    fwrite($fd, "/usr/bin/touch /tmp/install_complete\n");
    fclose($fd);
    exec("/bin/chmod a+rx /tmp/installer.sh");
    mwexec_bg("/bin/sh /tmp/installer.sh");
}
コード例 #3
0
header("Pragma: no-cache"); // HTTP/1.0
*/
require_once "guiconfig.inc";
class QueueStats
{
    public $queuename;
    public $queuelength;
    public $pps;
    public $bandwidth;
    public $borrows;
    public $suspends;
    public $drops;
}
if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_path']}/qstats.pid")) {
    /* Start in the background so we don't hang up the GUI */
    mwexec_bg("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid");
    /* Give it a moment to start up */
    sleep(1);
}
$fd = @fsockopen("unix://{$g['varrun_path']}/qstats");
if (!$fd) {
    $error = gettext("Something wrong happened during communication with stat gathering.");
} else {
    $stats = "";
    while (!feof($fd)) {
        $stats .= fread($fd, 4096);
    }
    fclose($fd);
    @file_put_contents("{$g['tmp_path']}/qstats", $stats);
    $altqstats = @parse_xml_config("{$g['tmp_path']}/qstats", array("altqstats"));
    if ($altqstats == -1) {
コード例 #4
0
            if (is_numeric($pconfig['filterdescriptions']) && $pconfig['filterdescriptions'] > 0) {
                $config['syslog']['filterdescriptions'] = $pconfig['filterdescriptions'];
            } elseif (isset($config['syslog']['filterdescriptions'])) {
                unset($config['syslog']['filterdescriptions']);
            }
            $config['rrd']['enable'] = !empty($pconfig['rrdenable']);
            write_config();
            $retval = 0;
            $retval = system_syslogd_start();
            if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']) || $oldnologdefaultpass !== isset($config['syslog']['nologdefaultpass']) || $oldnologbogons !== isset($config['syslog']['nologbogons']) || $oldnologprivatenets !== isset($config['syslog']['nologprivatenets'])) {
                $retval |= filter_configure();
            }
            $savemsg = get_std_save_message();
            if ($oldnologlighttpd !== isset($config['syslog']['nologlighttpd'])) {
                log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
                mwexec_bg('/usr/local/etc/rc.restart_webgui 2');
                $savemsg .= "<br />" . gettext("WebGUI process is restarting.");
            }
            filter_pflog_start();
            enable_rrd_graphing();
            setup_gateways_monitor();
        }
    }
}
legacy_html_escape_form_data($pconfig);
$closehead = false;
include "head.inc";
?>


コード例 #5
0
    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.");
// Done with post-install, so clear flag
unset($g['suricata_postinstall']);
コード例 #6
0
        exit;
    }
}
if ($_GET['deletefile']) {
    $filename = basename($_GET['deletefile']);
    if (file_exists("/root/{$filename}") && preg_match("/pfSense-full-backup-\\d+-\\d+\\.tgz/", $filename) == 1) {
        unlink("/root/" . $filename);
        $savemsg = htmlspecialchars($filename) . " " . gettext("has been deleted.");
    } else {
        $savemsg = htmlspecialchars($filename) . " " . gettext("has not been been deleted (invalid backup file or file does not exist).");
    }
}
if ($_POST['restorefile']) {
    $filename = basename($_POST['restorefile']);
    if (file_exists("/root/{$filename}") && preg_match("/pfSense-full-backup-\\d+-\\d+\\.tgz/", $filename) == 1) {
        mwexec_bg("/etc/rc.restore_full_backup /root/" . escapeshellcmd($filename));
        $savemsg = gettext("The firewall is currently restoring") . " " . htmlspecialchars($filename);
    } else {
        $savemsg = htmlspecialchars($filename) . " " . gettext("has not been been restored (invalid backup file or file does not exist).");
    }
}
$pgtitle = array(gettext("Diagnostics"), gettext("Restore full backup"));
include "head.inc";
?>

<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php 
include "fbegin.inc";
if ($input_errors) {
    print_input_errors($input_errors);
}
コード例 #7
0
ファイル: status_ipsec.php プロジェクト: NextMagic/pfsense
include "head.inc";
require_once "ipsec.inc";
if ($_GET['act'] == 'connect') {
    if (ctype_digit($_GET['ikeid'])) {
        $ph1ent = ipsec_get_phase1($_GET['ikeid']);
        if (!empty($ph1ent)) {
            if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == 'ikev1') {
                $ph2entries = ipsec_get_number_of_phase2($_GET['ikeid']);
                for ($i = 0; $i < $ph2entries; $i++) {
                    $connid = escapeshellarg("con{$_GET['ikeid']}00{$i}");
                    mwexec("/usr/local/sbin/ipsec down {$connid}");
                    mwexec_bg("/usr/local/sbin/ipsec up {$connid}");
                }
            } else {
                mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
                mwexec_bg("/usr/local/sbin/ipsec up con" . escapeshellarg($_GET['ikeid']));
            }
        }
    }
} else {
    if ($_GET['act'] == 'ikedisconnect') {
        if (ctype_digit($_GET['ikeid'])) {
            if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) {
                mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "[" . escapeshellarg($_GET['ikesaid']) . "]");
            } else {
                mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
            }
        }
    } else {
        if ($_GET['act'] == 'childdisconnect') {
            if (ctype_digit($_GET['ikeid'])) {
コード例 #8
0
    if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) {
        mwexec_bg(HVDEF_HAVP_STARTUP_SCRIPT . " start");
        sleep(3);
    }
    /* Restart service */
} elseif ($_POST['restart'] != '') {
    // restart_service($_POST['restart']);
    if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) {
        mwexec_bg(HVDEF_HAVP_STARTUP_SCRIPT . " restart");
        sleep(3);
    }
    /* Stop service */
} elseif ($_POST['stop'] != '') {
    // stop_service($_POST['stop']);
    if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) {
        mwexec_bg(HVDEF_HAVP_STARTUP_SCRIPT . " stop");
        sleep(3);
    }
}
/* Scan start */
if ($_POST['scanpath'] != '') {
    $scandir = $_POST['scanpath'];
    if (function_exists("start_antivirus_scanner")) {
        start_antivirus_scanner($scandir);
    }
}
/* Start AV Update */
if ($_POST['startupdate'] != '') {
    if (function_exists("havp_update_AV")) {
        havp_update_AV();
    }
コード例 #9
0
ファイル: xmlrpc.php プロジェクト: KyleJohnstonNet/pfsense
 /**
  * Wrapper for rc.reboot
  *
  * @param string $username
  * @param string $password
  *
  * @return bool
  */
 public function reboot($username, $password)
 {
     $this->auth($username, $password);
     mwexec_bg("/etc/rc.reboot");
     return true;
 }
コード例 #10
0
    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.");
/* Done with post-install, so clear flag */
unset($g['snort_postinstall']);
コード例 #11
0
ファイル: system_firmware.php プロジェクト: dariomas/pfsense
                    run_plugins("/usr/local/pkg/firmware_upgrade");
                    /* Check for input errors, firmware locks, warnings, then check for firmware if sig_override is set */
                    if (!$input_errors && !is_subsystem_dirty('firmwarelock') && (!$sig_warning || $_POST['sig_override'])) {
                        if (file_exists("{$g['upload_path']}/firmware.tgz")) {
                            /* fire up the update script in the background */
                            mark_subsystem_dirty('firmwarelock');
                            $savemsg = gettext("The firmware is now being updated. The firewall will reboot automatically.");
                            if (stristr($_FILES['ulfile']['name'], "nanobsd") or $_POST['isnano'] == "yes") {
                                mwexec_bg("/etc/rc.firmware pfSenseNanoBSDupgrade {$g['upload_path']}/firmware.tgz");
                            } else {
                                if ($g['platform'] == "nanobsd") {
                                    $whichone = "pfSenseNanoBSDupgrade";
                                } else {
                                    $whichone = "pfSenseupgrade";
                                }
                                mwexec_bg("/etc/rc.firmware {$whichone} {$g['upload_path']}/firmware.tgz");
                                unset($whichone);
                            }
                        } else {
                            $savemsg = sprintf(gettext("Firmware image missing or other error, please try again %s."), $errortext);
                        }
                    }
                }
            }
        }
    }
}
$pgtitle = array(gettext("System"), gettext("Firmware"));
include "head.inc";
if ($input_errors) {
    print_input_errors($input_errors);
コード例 #12
0
ファイル: status_services.php プロジェクト: rdmenezes/pfsense
        case 'igmpproxy':
            services_igmpproxy_configure();
            break;
        case 'miniupnpd':
            upnp_action('start');
            break;
        case 'racoon':
            vpn_ipsec_force_reload();
            break;
        case 'openvpn':
            $vpnmode = $_GET['vpnmode'];
            if ($vpnmode == "server" || $vpnmode == "client") {
                $id = $_GET['id'];
                $configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
                if (file_exists($configfile)) {
                    mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
                }
            }
            break;
        case 'relayd':
            relayd_configure();
            break;
        default:
            start_service($_GET['service']);
            break;
    }
    $savemsg = sprintf(gettext("%s has been started."), htmlspecialchars($_GET['service']));
    sleep(5);
}
/* stop service */
if ($_GET['mode'] == "stopservice" && !empty($_GET['service'])) {
コード例 #13
0
/**
 *  start capture operation
 *  @param array $option, options to pass to tpcdump (interface, promiscuous, snaplen, fam, host, proto, port)
 */
function start_capture($options)
{
    $cmd_opts = array();
    $filter_opts = array();
    $intf = get_real_interface($options['interface']);
    $cmd_opts[] = '-i ' . $intf;
    if (empty($options['promiscuous'])) {
        // disable promiscuous mode
        $cmd_opts[] = '-p';
    }
    if (!empty($options['snaplen']) && is_numeric($options['snaplen'])) {
        // setup Packet Length
        $cmd_opts[] = '-s ' . $options['snaplen'];
    }
    if (!empty($options['count']) && is_numeric($options['count'])) {
        // setup count
        $cmd_opts[] = '-c ' . $options['count'];
    }
    if (!empty($options['fam']) && in_array($options['fam'], array('ip', 'ip6'))) {
        // filter address family
        $filter_opts[] = $options['fam'];
    }
    if (!empty($options['proto'])) {
        // filter protocol
        $filter_opts[] = $options['proto'];
    }
    if (!empty($options['host'])) {
        // filter host argument
        $filter = '';
        $prev_token = '';
        foreach (explode(' ', $options['host']) as $token) {
            if (in_array(trim($token), array('and', 'or'))) {
                $filter .= $token;
            } elseif (is_ipaddr($token)) {
                $filter .= "host " . $prev_token . " " . $token;
            } elseif (is_subnet($token)) {
                $filter .= "net " . $prev_token . " " . $token;
            }
            if (trim($token) == 'not') {
                $prev_token = 'not';
            } else {
                $prev_token = '';
            }
            $filter .= " ";
        }
        $filter_opts[] = "( " . $filter . " )";
    }
    if (!empty($options['port'])) {
        // filter port
        $filter_opts[] = "port " . str_replace("!", "not ", $options['port']);
    }
    if (!empty($intf)) {
        $cmd = '/usr/sbin/tcpdump ';
        $cmd .= implode(' ', $cmd_opts);
        $cmd .= ' -w /root/packetcapture.cap ';
        $cmd .= " " . escapeshellarg(implode(' and ', $filter_opts));
        //delete previous packet capture if it exists
        if (file_exists('/root/packetcapture.cap')) {
            unlink('/root/packetcapture.cap');
        }
        mwexec_bg($cmd);
    }
}
コード例 #14
0
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/
require_once 'config.inc';
require_once 'util.inc';
$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
if ($pf_version > 2.0) {
    define('SQUID_LOCALBASE', '/usr/pbi/squid-' . php_uname("m"));
} else {
    define('SQUID_LOCALBASE', '/usr/local');
}
$settings = $config['installedpackages']['squidcache']['config'][0];
// Only check the cache if Squid is actually caching.
// If there is no cache then quietly do nothing.
if ($settings['harddisk_cache_system'] != "null") {
    $cachedir = $settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache';
    $swapstate = $cachedir . '/swap.state';
    $disktotal = disk_total_space(dirname($cachedir));
    $diskfree = disk_free_space(dirname($cachedir));
    $diskusedpct = round(($disktotal - $diskfree) / $disktotal * 100);
    $swapstate_size = filesize($swapstate);
    $swapstate_pct = round($swapstate_size / $disktotal * 100);
    // If the swap.state file is taking up more than 75% disk space,
    //	or the drive is 90% full and swap.state is larger than 1GB,
    //	kill it and initiate a rotate to write a fresh copy.
    if ($swapstate_pct > 75 || $diskusedpct > 90 && $swapstate_size > 1024 * 1024 * 1024) {
        mwexec_bg("/bin/rm {$swapstate}; " . SQUID_LOCALBASE . "/sbin/squid -k rotate");
        log_error(gettext(sprintf("Squid swap.state file exceeded size limits. Removing and rotating. File was %d bytes, %d%% of total disk space.", $swapstate_size, $swapstate_pct)));
    }
}
コード例 #15
0
function pfb_cron_update($type)
{
    global $pfb;
    // Query for any active pfBlockerNG CRON jobs
    exec('/bin/ps -wx', $result_cron);
    if (preg_grep("/pfblockerng[.]php\\s+?(cron|update)/", $result_cron)) {
        pfbupdate_status(gettext("Force {$type} Terminated - Failed due to Active Running Task. Click 'View' for running process"));
        exit;
    }
    if (!file_exists("{$pfb['log']}")) {
        touch("{$pfb['log']}");
    }
    // Update status window with correct task
    if ($type == 'update') {
        pfbupdate_status(gettext('Running Force Update Task'));
    } elseif ($type == 'reload') {
        $reload_type = htmlspecialchars($_POST['rmode']);
        pfbupdate_status(gettext("Running Force Reload Task - {$reload_type}"));
        switch ($reload_type) {
            case 'IP':
                $type = 'updateip';
                break;
            case 'DNSBL':
                $type = 'updatednsbl';
                rmdir_recursive("{$pfb['dnsdir']}");
                break;
            case 'All':
            default:
                $type = 'update';
                rmdir_recursive("{$pfb['dnsdir']}");
        }
    } else {
        pfbupdate_status(gettext('Running Force CRON Task'));
    }
    // Remove any existing pfBlockerNG CRON Jobs
    install_cron_job('pfblockerng.php cron', false);
    // Execute PHP process in the background
    mwexec_bg("/usr/local/bin/php /usr/local/www/pfblockerng/pfblockerng.php {$type} >> {$pfb['log']} 2>&1");
    // Execute Live Tail function
    pfb_livetail($pfb['log'], 'force');
}
コード例 #16
0
                        }
                    }
                    run_plugins("/usr/local/pkg/firmware_upgrade");
                    /* Check for input errors, firmware locks, warnings, then check for firmware if sig_override is set */
                    if (!$input_errors && !file_exists($d_firmwarelock_path) && (!$sig_warning || $_POST['sig_override'])) {
                        if (file_exists("{$g['upload_path']}/firmware.tgz")) {
                            /* fire up the update script in the background */
                            touch($d_firmwarelock_path);
                            $savemsg = "Güncelleme yüklendi. Birazdan otomatik olarak yeniden başlatılacaktır.";
                            if (stristr($_FILES['ulfile']['name'], "nanobsd") or $_POST['isnano'] == "yes") {
                                mwexec_bg("/etc/rc.firmware pfSenseNanoBSDupgrade {$g['upload_path']}/firmware.tgz");
                            } else {
                                if (stristr($_FILES['ulfile']['name'], "bdiff")) {
                                    mwexec_bg("/etc/rc.firmware delta_update {$g['upload_path']}/firmware.tgz");
                                } else {
                                    mwexec_bg("/etc/rc.firmware pfSenseupgrade {$g['upload_path']}/firmware.tgz");
                                }
                            }
                        } else {
                            $savemsg = "Güncelleme imajı kayıp veya başka bir hata ile karşılaşıldı, lütfen tekrar deneyiniz.";
                        }
                    }
                }
            }
        }
    }
}
$pgtitle = "System: Firmware: Elle Güncelleme";
include "head.inc";
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
コード例 #17
0
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/
require_once 'config.inc';
require_once 'util.inc';
$settings = $config['installedpackages']['squidcache']['config'][0];
// Only check the cache if Squid is actually caching.
// If there is no cache then quietly do nothing.
if ($settings['harddisk_cache_system'] != "null") {
    $cachedir = $settings['harddisk_cache_location'] ? $settings['harddisk_cache_location'] : '/var/squid/cache';
    $swapstate = $cachedir . '/swap.state';
    if (!file_exists($swapstate)) {
        return;
    }
    $disktotal = disk_total_space(dirname($cachedir));
    $diskfree = disk_free_space(dirname($cachedir));
    $diskusedpct = round(($disktotal - $diskfree) / $disktotal * 100);
    $swapstate_size = filesize($swapstate);
    $swapstate_pct = round($swapstate_size / $disktotal * 100);
    // If the swap.state file is taking up more than 75% disk space,
    //	or the drive is 90% full and swap.state is larger than 1GB,
    //	kill it and initiate a rotate to write a fresh copy.
    if ($swapstate_pct > 75 || $diskusedpct > 90 && $swapstate_size > 1024 * 1024 * 1024) {
        mwexec_bg("/bin/rm {$swapstate}; /usr/local/sbin/squid -k rotate");
        log_error(gettext(sprintf("Squid swap.state file exceeded size limits. Removing and rotating. File was %d bytes, %d%% of total disk space.", $swapstate_size, $swapstate_pct)));
    }
}
コード例 #18
0
                    }
                }
            }
            echo ">>> Processing {$build}\n";
            $category = trim(`echo \\"{$build}\\" | cut -d'/' -f4`);
            $port = trim(`echo \\"{$build}\\" | cut -d'/' -f5 | cut -d'"' -f1`);
            echo ">>> Category: {$category}/{$port} \n";
            if ($build_options) {
                if (!isset($options['q'])) {
                    echo " BUILD_OPTIONS: {$build_options}\n";
                }
            }
            $pbi_conf = create_pbi_conf($build, $build_options);
            if (!is_dir("/pbi-build/modules/{$category}/{$port}")) {
                exec("mkdir -p /pbi-build/modules/{$category}/{$port}");
            }
            file_put_contents("/pbi-build/modules/{$category}/{$port}/pbi.conf", $pbi_conf);
            echo ">>> Executing /usr/local/sbin/pbi_makeport -o /usr/ports/packages/All/ {$category}/{$port}\n";
            mwexec_bg("/usr/local/sbin/pbi_makeport -o /usr/ports/packages/All/ {$category}/{$port}");
            wait_for_procs_finish();
        }
    }
}
echo ">>> {$file_system_root}/usr/ports/packages/All now contains:\n";
system("ls {$file_system_root}/usr/ports/packages/All");
// Copy created packages to the package server via rsync
if ($copy_packages_to_folder_ssh) {
    echo ">>> Copying packages to {$copy_packages_to_host_ssh}\n";
    system("/usr/local/bin/rsync -ave ssh --timeout=60 --rsh='ssh -p{$copy_packages_to_host_ssh_port}' {$file_system_root}/usr/ports/packages/All/* {$copy_packages_to_host_ssh}:{$copy_packages_to_folder_ssh}/");
}
echo ">>> Package binary build run ended.\n";
コード例 #19
0
            $matches[] = "({$hostmatch})";
        }
    }
    if ($count != "0") {
        $searchcount = "-c " . $count;
    } else {
        $searchcount = "";
    }
    $selectedif = convert_friendly_interface_to_real_interface_name($selectedif);
    if ($action == gettext("Start")) {
        $matchstr = implode($matches, " and ");
        print_info_box(gettext('Packet Capture is running'), 'info');
        $cmd = "/usr/sbin/tcpdump -i {$selectedif} {$disablepromiscuous} {$searchcount} -s {$snaplen} -w {$fp}{$fn} " . escapeshellarg($matchstr);
        // Debug
        //echo $cmd;
        mwexec_bg($cmd);
    } else {
        ?>

<div class="panel panel-default">
	<div class="panel-heading"><h2 class="panel-title"><?php 
        echo gettext('Packets Captured');
        ?>
</h2></div>
	<div class="panel-body">
		<div class="form-group">
<?php 
        $detail_args = "";
        switch ($detail) {
            case "full":
                $detail_args = "-vv -e";
コード例 #20
0
}
if ($_POST['Download'] && ($bogons || $urltable)) {
    if ($bogons) {
        // If selected table is either bogons or bogonsv6.
        $mwexec_bg_cmd = '/etc/rc.update_bogons.sh now';
        $table_type = 'bogons';
        $db_name = 'bogons';
    } else {
        if ($urltable) {
            //  If selected table is a URL table alias.
            $mwexec_bg_cmd = '/etc/rc.update_urltables now forceupdate ' . $tablename;
            $table_type = 'urltables';
            $db_name = $tablename;
        }
    }
    mwexec_bg($mwexec_bg_cmd);
    $maxtimetowait = 0;
    $loading = true;
    while ($loading == true) {
        $isrunning = `/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep {$table_type}`;
        if ($isrunning == "") {
            $loading = false;
        }
        $maxtimetowait++;
        if ($maxtimetowait > 89) {
            $loading = false;
        }
        sleep(1);
    }
    if ($maxtimetowait < 90) {
        $savemsg = sprintf(gettext("The %s file contents have been updated."), $db_name);
コード例 #21
0
                $progbar = false;
                // We don't show the progress bar for reinstallall. It would be far too confusing
                mwexec_bg("{$upgrade_script} -i ALL_PACKAGES -f");
                $start_polling = true;
            }
            break;
        case 'reinstallpkg':
            mwexec_bg("{$upgrade_script} -i {$pkgid} -f");
            $start_polling = true;
            break;
        case 'installed':
        default:
            if ($pkgid == 'firmware') {
                mwexec_bg("{$upgrade_script}");
            } else {
                mwexec_bg("{$upgrade_script} -i {$pkgid}");
            }
            $start_polling = true;
            break;
    }
}
// $_POST['completed'] just means that we are refreshing the page to update any new menu items
// that were installed
if ($_POST && $_POST['completed'] == "true") {
    if ($pkgid == 'firmware') {
        ?>
<script>
//<![CDATA[
events.push(function(){
	startCountdown("<?php 
        echo $reloadtimer;
コード例 #22
0
ファイル: xmlrpc.php プロジェクト: michaeleino/pfsense
function reboot_xmlrpc($raw_params)
{
    global $xmlrpc_g;
    $params = xmlrpc_params_to_php($raw_params);
    if (!xmlrpc_auth($params)) {
        xmlrpc_authfail();
        return $xmlrpc_g['return']['authfail'];
    }
    mwexec_bg("/etc/rc.reboot");
    return $xmlrpc_g['return']['true'];
}
コード例 #23
0
                $progbar = false;
                // We don't show the progress bar for reinstallall. It would be far too confusing
                mwexec_bg("{$upgrade_script} -i ALL_PACKAGES -f");
                $start_polling = true;
            }
            break;
        case 'reinstallpkg':
            mwexec_bg("{$upgrade_script} -i {$pkgname} -f");
            $start_polling = true;
            break;
        case 'installed':
        default:
            if ($firmwareupdate) {
                mwexec_bg("{$upgrade_script}");
            } else {
                mwexec_bg("{$upgrade_script} -i {$pkgname}");
            }
            $start_polling = true;
            break;
    }
}
$uptodatemsg = gettext("Up to date.");
$confirmlabel = gettext("Confirm Update");
$sysmessage = gettext("Status");
// $completed just means that we are refreshing the page to update any new menu items
// that were installed
if ($completed) {
    unlink_if_exists($logfilename . ".json");
    // If this was a firmware update and a reboot was initiated, display the "Rebooting" message
    // and start the countdown timer
    if ($firmwareupdate && $reboot_needed) {
コード例 #24
0
ファイル: diag_tables.php プロジェクト: Toudix/core
        exec("/sbin/pfctl -t " . escapeshellarg($_REQUEST['type']) . " -T delete " . escapeshellarg($_REQUEST['delete']), $delete);
        echo htmlentities($_REQUEST['delete']);
    }
    exit;
}
if ($_REQUEST['deleteall']) {
    exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T show", $entries);
    if (is_array($entries)) {
        foreach ($entries as $entryA) {
            $entry = trim($entryA);
            exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T delete " . escapeshellarg($entry), $delete);
        }
    }
}
if (($tablename == "bogons" || $tablename == "bogonsv6") && $_POST['Download']) {
    mwexec_bg('/usr/local/etc/rc.update_bogons now');
    $maxtimetowait = 0;
    $loading = true;
    while ($loading == true) {
        $isrunning = `/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep bogons`;
        if ($isrunning == "") {
            $loading = false;
        }
        $maxtimetowait++;
        if ($maxtimetowait > 89) {
            $loading = false;
        }
        sleep(1);
    }
    if ($maxtimetowait < 90) {
        $savemsg = gettext("The bogons database has been updated.");
コード例 #25
0
ファイル: interfaces_lagg.php プロジェクト: mtisza/pfsense
            }
        }
    }
    return false;
}
if ($_GET['act'] == "del") {
    if (!isset($_GET['id'])) {
        $input_errors[] = gettext("Wrong parameters supplied");
    } else {
        if (empty($a_laggs[$_GET['id']])) {
            $input_errors[] = gettext("Wrong index supplied");
        } else {
            if (lagg_inuse($_GET['id'])) {
                $input_errors[] = gettext("This LAGG interface cannot be deleted because it is still being used.");
            } else {
                mwexec_bg("/sbin/ifconfig " . $a_laggs[$_GET['id']]['laggif'] . " destroy");
                unset($a_laggs[$_GET['id']]);
                write_config();
                header("Location: interfaces_lagg.php");
                exit;
            }
        }
    }
}
$pgtitle = array(gettext("Interfaces"), gettext("LAGG"));
$shortcut_section = "interfaces";
include "head.inc";
?>

<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php 
コード例 #26
0
        $searchport = "";
    }
    if ($host != "") {
        $searchhost = "host " . $host;
    } else {
        $searchhost = "";
    }
    if ($count != "0") {
        $searchcount = "-c " . $count;
    } else {
        $searchcount = "";
    }
    $selectedif = convert_friendly_interface_to_real_interface_name($selectedif);
    if ($action == "Start") {
        echo "<strong>Paket Yakalama şu anda çalışıyor.</strong><br/>";
        mwexec_bg("/usr/sbin/tcpdump -i {$selectedif} {$searchcount} -s {$packetlength} -w {$fp}{$fn} {$searchhost} {$searchport}");
    } else {
        echo "<strong>Packet Capture stopped. <br/><br/>Packetler Yakalandı:</strong><br/>";
        ?>
						<textarea style="width:98%" name="code" rows="15" cols="66" wrap="off" readonly="readonly">
						<?php 
        system("/usr/sbin/tcpdump {$disabledns} {$detail} -r {$fp}{$fn}");
        ?>
						</textarea><?php 
    }
}
?>
				</td>
				</tr>
				<tr>
コード例 #27
0
        conf_mount_ro();
    }
    require "fend.inc";
    exit;
}
if ($downloaded_latest_tgz_sha256 != $upgrade_latest_tgz_sha256) {
    update_status(gettext("Downloading complete but sha256 does not match."));
    update_output_window(gettext("Auto upgrade aborted.") . "  \n\n" . gettext("Downloaded SHA256") . ": " . $downloaded_latest_tgz_sha256 . "\n\n" . gettext("Needed SHA256") . ": " . $upgrade_latest_tgz_sha256);
} else {
    update_output_window($g['product_name'] . " " . gettext("is now upgrading.") . "\\n\\n" . gettext("The firewall will reboot once the operation is completed."));
    echo "\n<script type=\"text/javascript\">";
    echo "\n//<![CDATA[";
    echo "\ndocument.progressbar.style.visibility='hidden';";
    echo "\n//]]>";
    echo "\n</script>";
    mwexec_bg($external_upgrade_helper_text);
}
/*
	Helper functions
*/
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";
コード例 #28
0
ファイル: diag_tables.php プロジェクト: mtisza/pfsense
        exec("/sbin/pfctl -t " . escapeshellarg($_REQUEST['type']) . " -T delete " . escapeshellarg($_REQUEST['delete']), $delete);
        echo htmlentities($_REQUEST['delete']);
    }
    exit;
}
if ($_REQUEST['deleteall']) {
    exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T show", $entries);
    if (is_array($entries)) {
        foreach ($entries as $entryA) {
            $entry = trim($entryA);
            exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T delete " . escapeshellarg($entry), $delete);
        }
    }
}
if (($tablename == "bogons" || $tablename == "bogonsv6") && $_POST['Download']) {
    mwexec_bg("/etc/rc.update_bogons.sh now");
    $maxtimetowait = 0;
    $loading = true;
    while ($loading == true) {
        $isrunning = `/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep bogons`;
        if ($isrunning == "") {
            $loading = false;
        }
        $maxtimetowait++;
        if ($maxtimetowait > 89) {
            $loading = false;
        }
        sleep(1);
    }
    if ($maxtimetowait < 90) {
        $savemsg = gettext("The bogons database has been updated.");
コード例 #29
0
ファイル: status_wireless.php プロジェクト: mtisza/pfsense
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<?php 
$tab_array = array();
foreach ($ciflist as $interface => $ifdescr) {
    if (is_interface_wireless(get_real_interface($interface))) {
        $enabled = false;
        if ($if == $interface) {
            $enabled = true;
        }
        $tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
    }
}
$rwlif = get_real_interface($if);
if ($_POST['rescanwifi'] != "") {
    mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
    $savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
}
if ($savemsg) {
    print_info_box($savemsg);
}
display_top_tabs($tab_array);
?>
</td></tr>
<tr><td>
<div id="mainarea" class="tabcont">
<input type="hidden" name="if" id="if" value="<?php 
echo htmlspecialchars($if);
?>
">
<b><input type="submit" name="rescanwifi" id="rescanwifi" value="Rescan"></b><br /><br />
コード例 #30
0
function pfb_cron_update($type)
{
    global $pfb;
    // Query for any Active pfBlockerNG CRON Jobs
    $result_cron = array();
    $cron_event = exec("/bin/ps -wx", $result_cron);
    if (preg_grep("/pfblockerng[.]php\\s+cron/", $result_cron) || preg_grep("/pfblockerng[.]php\\s+update/", $result_cron)) {
        pfbupdate_status(gettext("Force {$type} Terminated - Failed due to Active Running Task"));
        exit;
    }
    if (!file_exists("{$pfb['log']}")) {
        touch("{$pfb['log']}");
    }
    // Update Status Window with correct Task
    if ($type == "update") {
        pfbupdate_status(gettext("Running Force Update Task"));
    } elseif ($type == "reload") {
        pfbupdate_status(gettext("Running Force Reload Task"));
        $type = "update";
    } else {
        pfbupdate_status(gettext("Running Force CRON Task"));
    }
    // Remove any existing pfBlockerNG CRON Jobs
    install_cron_job("pfblockerng.php cron", false);
    // Execute PHP Process in the Background
    mwexec_bg("/usr/local/bin/php /usr/local/www/pfblockerng/pfblockerng.php {$type} >> {$pfb['log']} 2>&1");
    // Start at EOF
    $lastpos_old = "";
    $len = filesize("{$pfb['log']}");
    $lastpos = $len;
    while (true) {
        usleep(300000);
        //0.3s
        clearstatcache(false, $pfb['log']);
        $len = filesize("{$pfb['log']}");
        if ($len < $lastpos) {
            //file deleted or reset
            $lastpos = $len;
        } else {
            $f = fopen($pfb['log'], "rb");
            if ($f === false) {
                die;
            }
            fseek($f, $lastpos);
            while (!feof($f)) {
                $pfb_buffer = fread($f, 2048);
                $pfb_output .= str_replace(array("\r", "\")"), "", $pfb_buffer);
                // Refresh on new lines only. This allows Scrolling.
                if ($lastpos != $lastpos_old) {
                    pfbupdate_output($pfb_output);
                }
                $lastpos_old = $lastpos;
                ob_flush();
                flush();
            }
            $lastpos = ftell($f);
            fclose($f);
        }
        // Capture Remaining Output before closing File
        if (preg_match("/(UPDATE PROCESS ENDED)/", $pfb_output)) {
            $f = fopen($pfb['log'], "rb");
            fseek($f, $lastpos);
            $pfb_buffer = fread($f, 2048);
            $pfb_output .= str_replace("\r", "", $pfb_buffer);
            pfbupdate_output($pfb_output);
            clearstatcache(false, $pfb['log']);
            ob_flush();
            flush();
            fclose($f);
            // Call Log Mgmt Function
            pfb_log_mgmt();
            die;
        }
    }
}