From 0af32b6aab2f30fe05ad526f9dcdaca3f82653de Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 31 May 2015 18:01:10 +0000 Subject: [PATCH] (captiveportal) let rc scripting handle ipfw/dummynet module loading --- src/etc/inc/captiveportal.inc | 16 ---------------- .../models/OPNsense/CaptivePortal/CPClient.php | 9 +++++---- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc index c65aa1ff3..078d5a1ac 100644 --- a/src/etc/inc/captiveportal.inc +++ b/src/etc/inc/captiveportal.inc @@ -329,20 +329,6 @@ EOD; return $htmltext; } -function captiveportal_load_modules() { - global $config; - - mute_kernel_msgs(); - if (!is_module_loaded("ipfw.ko")) { - mwexec("/sbin/kldload ipfw"); - } - /* Always load dummynet now that even allowed ip and mac passthrough use it. */ - if (!is_module_loaded("dummynet.ko")) { - mwexec("/sbin/kldload dummynet"); - set_sysctl(array("net.inet.ip.dummynet.io_fast" => "1", "net.inet.ip.dummynet.hash_size" => "256")); - } - unmute_kernel_msgs(); -} function captiveportal_configure() { global $config, $cpzone, $cpzoneid; @@ -352,8 +338,6 @@ function captiveportal_configure() { $cpc = new OPNsense\CaptivePortal\CPClient(); if ($cpc->isEnabled()) { - // load modules ( only if CP is enabled ) - captiveportal_load_modules(); $cpc->reconfigure(); } diff --git a/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php b/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php index ccafad533..b278eda70 100644 --- a/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php +++ b/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php @@ -91,14 +91,14 @@ class CPClient */ public function reconfigure() { + $backend = new Backend(); if ($this->isEnabled()) { $ruleset_filename = FactoryDefault::getDefault()->get('config')->globals->temp_path."/ipfw.rules"; - $backend = new Backend(); $response = $backend->configdRun("template reload OPNsense.IPFW"); if (trim($response) == "OK") { // load ruleset when ruleset is successfully loaded - $this->shell->exec("/sbin/ipfw -f ".$ruleset_filename); + $this->shell->exec("/etc/rc.d/ipfw start"); } // update tables @@ -107,8 +107,9 @@ class CPClient // after reinit all accounting rules are vanished, reapply them for active sessions $this->loadAccounting(); } else { - // captiveportal is disabled, flush all rules to be sure - $this->shell->exec("/sbin/ipfw -f flush"); + // captiveportal is disabled, create new config and reload ipfw + $response = $backend->configdRun("template reload OPNsense.IPFW"); + $this->shell->exec("/etc/rc.d/ipfw start"); } }