From ff12f2bc124b7ffa7ff71acd7911ee279d6f6464 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 17 Nov 2015 17:30:22 +0100 Subject: olsrd package fixes, add privileges configuration - Fix service handling - Add input validations - Disable the dynamic gateways options since the required plugin is missing in the package - Couple of other clenaups --- config/olsrd/olsrd.xml | 111 ++++++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 43 deletions(-) (limited to 'config') diff --git a/config/olsrd/olsrd.xml b/config/olsrd/olsrd.xml index 6623c31f..8023f818 100644 --- a/config/olsrd/olsrd.xml +++ b/config/olsrd/olsrd.xml @@ -9,7 +9,7 @@ /* olsrd.xml part of pfSense (https://www.pfSense.org/) - Copyright (C) 2012 Ermal Luçi + Copyright (C) 2006 Scott Ullrich Copyright (C) 2015 ESF, LLC All rights reserved. */ @@ -42,37 +42,58 @@ ]]> olsrd - 1.0.3 - OLSRD + 1.0.4 + Services: OLSRD Settings /usr/local/pkg/olsrd.inc OLSRD
Services
olsrd.xml + /pkg_edit.php?xml=olsrd.xml
- OLSRD - /usr/local/sbin/olsrd -f /var/etc/olsr.conf + olsrd + olsrd.sh + olsrd + Optimized Link State Routing Protocol Daemon - - - OLSRD Settings - /pkg_edit.php?xml=olsrd.xml&id=0 - - - /usr/local/pkg/ https://packages.pfsense.org/packages/config/olsrd/olsrd.inc - ['installedpackages']['OLSRD']['config'] + + /etc/inc/priv/ + https://packages.pfsense.org/packages/config/olsrd/olsrd.priv.inc + + + Service Settings + listtopic + Enable OLSR enable Enables the dynamic mesh linking daemon. checkbox + + Enable Secure Mode + enabledsecure + Enables the secure mode. + checkbox + + + Key + securekey + Paste the secure key information here. + textarea + 5 + 50 + + + General Settings + listtopic + Link Quality Level enablelqe @@ -83,6 +104,7 @@ + 2 Interfaces @@ -98,6 +120,7 @@ enablehttpinfo Enables the OLSR stats web server. checkbox + port,allowedhttpinfohost,allowedhttpinfosubnet HTTPInfo Port @@ -106,65 +129,67 @@ input - Allowed host(s) + Allowed Host(s) IP Address/Subnet allowedhttpinfohost - Hosts that are allowed to access the HTTPInfo web service. + IP(s) that are allowed to access the HTTPInfo web service. input - Allowed host(s) subnet + Allowed Host(s) Netmask allowedhttpinfosubnet - Enter the subnet mask in form 255.255.255.0 + Enter the subnet mask in long form (e.g. 255.255.255.0) input - Enable Dynamic Gateway - enabledyngw - Enables the OLSR Dynamic Gateways feature. - checkbox - - - Announce self as Dynamic Gateway + Announce Self as Dynamic Gateway enableannounce Enables the OLSR Dynamic Gateways Announcing feature. checkbox - Announce Dynamic local route + Announce Dynamic Local Route announcedynamicroute Enter the IP/Netmask. textarea 3 50 + + + + php_deinstall_olsrd(); + setup_wireless_olsr($if); + + validate_form_olsrd($_POST, $input_errors); + -- cgit v1.2.3 From 607bd9b118ffd32b53647464f8c01b4a1d488ee8 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 17 Nov 2015 17:35:02 +0100 Subject: olsrd package fixes - Fix service handling - Fix plugin paths - Disable the dynamic gateways options since the required plugin is missing in the package - Add input validations - Some other cleanups --- config/olsrd/olsrd.inc | 156 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 111 insertions(+), 45 deletions(-) (limited to 'config') diff --git a/config/olsrd/olsrd.inc b/config/olsrd/olsrd.inc index 4e15f9cf..f65c1168 100644 --- a/config/olsrd/olsrd.inc +++ b/config/olsrd/olsrd.inc @@ -2,7 +2,7 @@ /* olsrd.inc part of pfSense (https://www.pfSense.org/) - Copyright (C) 2012 Ermal Luçi + Copyright (C) 2006 Scott Ullrich Copyright (C) 2015 ESF, LLC All rights reserved. @@ -28,27 +28,36 @@ POSSIBILITY OF SUCH DAMAGE. */ require_once("config.inc"); +require_once("service-utils.inc"); +require_once("util.inc"); + +$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pfs_version == "2.1" || $pfs_version == "2.2") { + define('OLSRD_LOCALBASE', '/usr/pbi/olsrd-' . php_uname("m") . '/local'); +} else { + define('OLSRD_LOCALBASE', '/usr/local'); +} function setup_wireless_olsr() { global $config, $g; - if ($g['platform'] == 'jail' || !$config['installedpackages']['olsrd'] || !$config['installedpackages']) { - return; - } - if (isset($config['system']['developerspew'])) { - $mt = microtime(); - echo "setup_wireless_olsr($interface) being called $mt\n"; - } conf_mount_rw(); - foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) { - $olsr_enable = $olsrd['enable']; - if ($olsr_enable <> "on") { - if (is_process_running("olsrd")) { - mwexec("/usr/bin/killall olsrd", true); - } - return; + if (is_array($config['installedpackages']['olsrd'])) { + $olsrd_config = $config['installedpackages']['olsrd']['config'][0]; + } else { + $olsrd_config = array(); + } + + /* If disabled, stop service if needed, unlink the rc script and do nothing else */ + if ($olsrd_config['enable'] != "on") { + if (is_service_running("olsrd")) { + stop_service("olsrd"); } + unlink_if_exists("/usr/local/etc/rc.d/olsrd.sh"); + return; + } else { + /* parse package config and create configuration file */ $fd = fopen("{$g['varetc_path']}/olsr.conf", "w"); if ($olsrd['announcedynamicroute'] or $olsrd['enableannounce'] == "on") { @@ -64,7 +73,8 @@ function setup_wireless_olsr() { } else { $enableannounce = ""; } - + + $pluginpath = OLSRD_LOCALBASE . '/lib'; $olsr .= << "olsrd.sh", + "start" => $olsrd_start, + "stop" => $olsrd_stop + ) + ); + if (is_service_running("olsrd")) { + restart_service("olsrd"); + } else { + start_service("olsrd"); + } } - sleep(2); - mwexec_bg("/usr/local/sbin/olsrd -f {$g['varetc_path']}/olsr.conf"); conf_mount_ro(); } +function validate_form_olsrd($post, &$input_errors) { + /* + if ($post['iface_array'] == "") { + $input_errors[] = 'You must select at least one interface for OSLRD.'; + } + */ + if ($post['enablehttpinfo']) { + if (!$post['port'] || !$post['allowedhttpinfohost'] || !$post['allowedhttpinfosubnet']) { + $input_errors[] = "'HTTPInfo Port', 'Allowed Host(s) IP Address/Subnet' and 'Allowed Host(s) Netmask' must be filled in when HTTPInfo Plugin is enabled."; + } + if ($post['port'] && !is_port($post['port'])) { + $input_errors[] = "Invalid port entered for 'HTTPInfo Port'."; + } + if ($post['allowedhttpinfohost'] && !is_ipaddrv4($post['allowedhttpinfohost'])) { + $input_errors[] = "Invalid IPv4 address entered for 'Allowed Host(s) IP Address/Subnet'."; + } + if ($post['allowedhttpinfosubnet'] && !is_ipaddrv4($post['allowedhttpinfosubnet'])) { + $input_errors[] = "Invalid IPv4 address entered for 'Allowed Host(s) Netmask'."; + } + if ($post['allowedhttpinfohost'] && is_ipaddrv4($post['allowedhttpinfohost']) && $post['allowedhttpinfosubnet'] && is_ipaddrv4($post['allowedhttpinfosubnet'])) { + $cidr = 32 - log((ip2long($post['allowedhttpinfosubnet']) ^ ip2long('255.255.255.255')) + 1, 2); + $acl = "{$post['allowedhttpinfohost']}/{$cidr}"; + if (!is_subnetv4($acl)) { + $input_errors[] = "'{$post['allowedhttpinfohost']}/{$post['allowedhttpinfosubnet']}' is not a valid IPv4 subnet."; + } + } + } + if ($post['enabledyngw']) { + if (!$post['ping'] || !$post['polling']) { + $input_errors[] = "'Ping IP Address' and 'Poll Interval' must be filled in when 'Enable Dynamic Gateway' is checked."; + } + if ($post['ping'] && !is_ipaddrv4($post['ping'])) { + $input_errors[] = "Invalid IPv4 address entered for 'Ping IP Address'."; + } + if ($post['polling'] && (!is_numericint($post['polling']) || ($post['polling'] < 1))) { + $input_errors[] = "'Poll Interval' must be numeric integer greater than 0."; + } + } +} + +function php_deinstall_olsrd() { + global $g; + unlink_if_exists("{$g['varetc_path']}/olsr.conf"); + unlink_if_exists("{$g['tmp_path']}/olsrkey.txt"); +} + ?> -- cgit v1.2.3 From 5b3a7c0f3088ded1337b909ea9c4a2e036952e05 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 17 Nov 2015 17:38:13 +0100 Subject: Add privileges configuration to olsrd package --- config/olsrd/olsrd.priv.inc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 config/olsrd/olsrd.priv.inc (limited to 'config') diff --git a/config/olsrd/olsrd.priv.inc b/config/olsrd/olsrd.priv.inc new file mode 100644 index 00000000..159a2d36 --- /dev/null +++ b/config/olsrd/olsrd.priv.inc @@ -0,0 +1,37 @@ + -- cgit v1.2.3