summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorRyan Wagoner <rsw686@pfsense.org>2007-07-23 17:26:33 +0000
committerRyan Wagoner <rsw686@pfsense.org>2007-07-23 17:26:33 +0000
commit431484c8ef64f0f039333b8004106cb7d0f58def (patch)
tree6c6e1e42004fcb1d9e7687c93c7266287f4989a6 /usr
parenta097d3c06c96df8cefd75b7e85df4485d04f02d9 (diff)
downloadpfsense-431484c8ef64f0f039333b8004106cb7d0f58def.zip
pfsense-431484c8ef64f0f039333b8004106cb7d0f58def.tar.gz
-move upnp_action to services.inc
-make sure to clear rules when stopping miniupnpd -fix status_upnp and status_services pages so they use upnp_action and not the rcfile
Diffstat (limited to 'usr')
-rw-r--r--usr/local/pkg/miniupnpd.inc51
-rw-r--r--usr/local/pkg/miniupnpd.xml6
-rwxr-xr-xusr/local/www/status_services.php10
-rw-r--r--usr/local/www/status_upnp.php2
4 files changed, 9 insertions, 60 deletions
diff --git a/usr/local/pkg/miniupnpd.inc b/usr/local/pkg/miniupnpd.inc
index f4aa98c..5e1a204 100644
--- a/usr/local/pkg/miniupnpd.inc
+++ b/usr/local/pkg/miniupnpd.inc
@@ -9,22 +9,6 @@
function upnp_notice ($msg) { syslog(LOG_NOTICE, "miniupnpd: {$msg}"); return; }
function upnp_warn ($msg) { syslog(LOG_WARNING, "miniupnpd: {$msg}"); return; }
- function upnp_action ($action) {
- switch($action) {
- case "start":
- mwexec("killall miniupnpd 2>/dev/null");
- upnp_start();
- break;
- case "stop":
- mwexec("killall miniupnpd");
- break;
- case "restart":
- mwexec("killall miniupnpd");
- upnp_start();
- break;
- }
- }
-
function upnp_running () {
if((int)exec("pgrep miniupnpd | wc -l") > 0)
return true;
@@ -39,10 +23,10 @@
}
function upnp_write_config($conf_file, $conf_text) {
- $conf_file = "/var/etc/miniupnpd.conf";
$conf = fopen($conf_file, "w");
if(!$conf) {
upnp_warn("Could not open {$conf_file} for writing.");
+ echo "Could not open {$conf_file} for writing.";
exit;
}
fwrite($conf, $conf_text);
@@ -155,8 +139,6 @@
/* since config is written before this file invoked we don't need to read post data */
if(upnp_config('enable') && upnp_config('iface_array'))
$iface_array = explode(',',upnp_config('iface_array'));
- else
- upnp_action("stop");
if($iface_array) {
foreach($iface_array as $iface) {
@@ -234,28 +216,8 @@
if(upnp_config('permdefault'))
$configtext .= "deny 0-65535 0.0.0.0/0 0-65535\n";
- /* generate rc file start and stop */
- $stop = <<<EOD
-if [ `pgrep miniupnpd | wc -l` != 0 ]; then
- /usr/bin/killall miniupnpd
- while [ `pgrep miniupnpd | wc -l` != 0 ]; do
- sleep 1
- done
- fi
- # Clear existing rules and rdr entries
- if [ `pfctl -aminiupnpd -sr | wc -l` != 0 ]; then
- /sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null
- fi
- if [ `pfctl -aminiupnpd -sn | wc -l` != 0 ]; then
- /sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null
- fi
-EOD;
- $start = $stop."\n\t/usr/local/sbin/miniupnpd -f ".UPNP_CONFIG;
-
/* write out the configuration */
- conf_mount_rw();
upnp_write_config(UPNP_CONFIG,$configtext);
- conf_mount_ro();
/* if miniupnpd not running start it */
if(!upnp_running()) {
@@ -274,18 +236,15 @@ EOD;
/* no parameters user does not want miniupnpd running */
/* lets stop the service and remove the rc file */
- if(file_exists(UPNP_RCFILE)) {
+ if(file_exists(UPNP_CONFIG)) {
if(!upnp_config('enable'))
upnp_notice('Stopping service: miniupnpd disabled');
else
- upnp_notice('Stopping service: no interfaces selected');
-
- upnp_action('stop');
+ upnp_notice('Stopping service: no interfaces selected');
- conf_mount_rw();
- unlink(UPNP_RCFILE);
+ upnp_notice('Stopping service: miniupnpd disabled');
+ upnp_action('stop');
unlink(UPNP_CONFIG);
- conf_mount_ro();
}
}
diff --git a/usr/local/pkg/miniupnpd.xml b/usr/local/pkg/miniupnpd.xml
index bac2337..dc3b057 100644
--- a/usr/local/pkg/miniupnpd.xml
+++ b/usr/local/pkg/miniupnpd.xml
@@ -123,10 +123,4 @@
<custom_php_resync_config_command>
sync_package_miniupnpd();
</custom_php_resync_config_command>
- <custom_php_install_command>
- sync_package_miniupnpd();
- </custom_php_install_command>
- <custom_php_deinstall_command>
- exec("rm -f /usr/local/etc/rc.d/miniupnpd*");
- </custom_php_deinstall_command>
</packagegui>
diff --git a/usr/local/www/status_services.php b/usr/local/www/status_services.php
index 42c0da1..f603507 100755
--- a/usr/local/www/status_services.php
+++ b/usr/local/www/status_services.php
@@ -54,8 +54,7 @@ if($_GET['mode'] == "restartservice" and $_GET['service']) {
services_dhcpd_configure();
break;
case 'miniupnpd':
- if(file_exists('/usr/local/etc/rc.d/miniupnpd.sh'))
- mwexec('/usr/local/etc/rc.d/miniupnpd.sh restart');
+ upnp_action('restart');
break;
case 'racoon':
exec("killall -9 racoon");
@@ -95,8 +94,7 @@ if($_GET['mode'] == "startservice" and $_GET['service']) {
services_dhcpd_configure();
break;
case 'miniupnpd':
- if(file_exists('/usr/local/etc/rc.d/miniupnpd.sh'))
- mwexec('/usr/local/etc/rc.d/miniupnpd.sh start');
+ upnp_action('start');
break;
case 'racoon':
exec("killall -9 racoon");
@@ -140,9 +138,7 @@ if($_GET['mode'] == "stopservice" && $_GET['service']) {
killbypid("{$g['varrun_path']}/dnsmasq.pid");
break;
case 'miniupnpd':
- /* can't just killbyname since we need to clear pf rules */
- if(file_exists('/usr/local/etc/rc.d/miniupnpd.sh'))
- mwexec('/usr/local/etc/rc.d/miniupnpd.sh stop');
+ upnp_action('stop');
break;
case 'ntpd':
killbyname("ntpd");
diff --git a/usr/local/www/status_upnp.php b/usr/local/www/status_upnp.php
index f13c6d8..cea49a8 100644
--- a/usr/local/www/status_upnp.php
+++ b/usr/local/www/status_upnp.php
@@ -33,7 +33,7 @@ require("guiconfig.inc");
if ($_POST) {
if ($_POST['clear'] == "Clear") {
- mwexec("/bin/sh /usr/local/etc/rc.d/miniupnpd.sh restart");
+ upnp_action('restart');
$savemsg = "Rules have been cleared and the daemon restarted";
}
}
OpenPOWER on IntegriCloud