diff options
author | jim-p <jimp@pfsense.org> | 2011-04-29 10:44:53 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2011-04-29 10:45:47 -0400 |
commit | d186202dfa508cde7887c55f49d8385f76afba9b (patch) | |
tree | aeeb3d73036d92c3d77f4d0dbc873bb952730adb | |
parent | 86f69114fe89f3915d17e7937b7c146d743aee77 (diff) | |
download | pfsense-packages-d186202dfa508cde7887c55f49d8385f76afba9b.tar.gz pfsense-packages-d186202dfa508cde7887c55f49d8385f76afba9b.tar.bz2 pfsense-packages-d186202dfa508cde7887c55f49d8385f76afba9b.zip |
Cleanup any potentially empty/redundant pfflowd config entries before loading the form to edit settings. While I'm here, add input validation for required fields.
-rw-r--r-- | config/pfflowd.xml | 35 | ||||
-rwxr-xr-x | pkg_config.7.xml | 2 | ||||
-rwxr-xr-x | pkg_config.8.xml | 2 | ||||
-rwxr-xr-x | pkg_config.8.xml.amd64 | 2 |
4 files changed, 35 insertions, 6 deletions
diff --git a/config/pfflowd.xml b/config/pfflowd.xml index 6f2c7a0f..f8552189 100644 --- a/config/pfflowd.xml +++ b/config/pfflowd.xml @@ -77,11 +77,12 @@ </field> </fields> <custom_php_global_functions> + <![CDATA[ function sync_package_pfflowd() { conf_mount_rw(); - config_lock(); - global $config; - foreach($config['installedpackages']['pfflowd']['config'] as $cf) { + config_lock(); + global $config; + foreach($config['installedpackages']['pfflowd']['config'] as $cf) { if($cf['host'] != "") { $start = "\n/sbin/ifconfig pfsync0 up\n"; $start .= "/usr/local/sbin/pfflowd "; @@ -107,8 +108,36 @@ conf_mount_ro(); config_unlock(); } + + function validate_form_pfflowd($post, $input_errors) { + if(($post['host'] == "") || !is_ipaddr($post['host'])) + $input_errors[] = 'You must specify a valid ip address in the \'Host\' field'; + if(($post['port'] == "") || !is_port($post['port'])) + $input_errors[] = 'You must specify a valid port number in the \'Port\' field'; + } + + function cleanup_config_pfflowd() { + global $a_pkg; + $pffconf = array(); + if (is_array($a_pkg)) { + foreach($a_pkg as $cf) { + if($cf['host'] != "") { + $pffconf = $cf; + } + } + } + $a_pkg = array(); + $a_pkg[0] = $pffconf; + } + ]]> </custom_php_global_functions> <custom_php_resync_config_command> sync_package_pfflowd(); </custom_php_resync_config_command> + <custom_php_validation_command> + validate_form_pfflowd($_POST, &$input_errors); + </custom_php_validation_command> + <custom_php_command_before_form> + cleanup_config_pfflowd(); + </custom_php_command_before_form> </packagegui> diff --git a/pkg_config.7.xml b/pkg_config.7.xml index cf71452e..ede45e6c 100755 --- a/pkg_config.7.xml +++ b/pkg_config.7.xml @@ -648,7 +648,7 @@ <config_file>http://www.pfsense.com/packages/config/pfflowd.xml</config_file> <depends_on_package_base_url>http://files.pfsense.org/packages/7/All/</depends_on_package_base_url> <depends_on_package>pfflowd-0.8.tbz</depends_on_package> - <version>0.8.1</version> + <version>0.8.2</version> <status>Stable</status> <required_version>1.2.3</required_version> <configurationfile>pfflowd.xml</configurationfile> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 59c1e628..45652cf8 100755 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -606,7 +606,7 @@ <config_file>http://www.pfsense.com/packages/config/pfflowd.xml</config_file> <depends_on_package_base_url>http://files.pfsense.org/packages/8/All/</depends_on_package_base_url> <depends_on_package>pfflowd-0.8.tbz</depends_on_package> - <version>0.8.1</version> + <version>0.8.2</version> <status>Stable</status> <required_version>2.0</required_version> <configurationfile>pfflowd.xml</configurationfile> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 5c8af9b7..1895b04d 100755 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -636,7 +636,7 @@ <config_file>http://www.pfsense.com/packages/config/pfflowd.xml</config_file> <depends_on_package_base_url>http://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url> <depends_on_package>pfflowd-0.8.tbz</depends_on_package> - <version>0.8.1</version> + <version>0.8.2</version> <status>Stable</status> <required_version>2.0</required_version> <configurationfile>pfflowd.xml</configurationfile> |