From 7d12486648a34c36b14bedd3d6edf2f9a9b658d7 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Thu, 16 Oct 2014 16:51:41 +0200 Subject: haproxy-devel, fix php crash while installing package, trying to upgrade old configuration from a non existing array. --- config/haproxy-devel/haproxy.inc | 9 ++++----- config/haproxy-devel/haproxy_utils.inc | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc index e239ab8c..07086bd5 100644 --- a/config/haproxy-devel/haproxy.inc +++ b/config/haproxy-devel/haproxy.inc @@ -362,8 +362,6 @@ EOD; fclose($fd); exec("chmod a+rx /usr/local/etc/rc.d/haproxy.sh"); - - $static_output .= "HAProxy, update configuration\n"; update_output_window($static_output); @@ -418,7 +416,7 @@ EOD; } /* XML update to: pkg v1.3 and 'pool' changed to 'backend_serverpool' because 'pool' was added to listtags() in xmlparse.inc */ - if (is_array($config['installedpackages']['haproxy']['ha_backends']['item'][0]['pool'])) { + if (is_arrayset($config,'installedpackages','haproxy','ha_backends','item',0,'pool')) { $static_output .= "HAProxy, Do XML upgrade, change to backend_serverpool from pool array\n"; update_output_window($static_output); @@ -431,7 +429,8 @@ EOD; $writeconfigupdate = true; } //also move setting for existing 2.0 installations as only the new variable is used - if (isset($config['installedpackages']['haproxy']['ha_backends']['item'][0]['pool'])) { + if (is_arrayset($config,'installedpackages','haproxy','ha_backends','item',0) && + isset($config['installedpackages']['haproxy']['ha_backends']['item'][0]['pool'])) { $static_output .= "HAProxy, Do XML upgrade, change to backend_serverpool from pool\n"; update_output_window($static_output); foreach($config['installedpackages']['haproxy']['ha_backends']['item'] as &$frontend) @@ -443,7 +442,7 @@ EOD; $writeconfigupdate = true; } // update config to "haproxy-devel 1.5-dev19 pkg v0.5" - if(is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { + if(is_arrayset($config,'installedpackages','haproxy','ha_backends','item')) { $static_output .= "HAProxy, Do XML upgrade, update frontend options\n"; update_output_window($static_output); foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) { diff --git a/config/haproxy-devel/haproxy_utils.inc b/config/haproxy-devel/haproxy_utils.inc index 8fb89eab..08906bb0 100644 --- a/config/haproxy-devel/haproxy_utils.inc +++ b/config/haproxy-devel/haproxy_utils.inc @@ -44,6 +44,24 @@ if(!function_exists('ifset')){ }; } +if(!function_exists('is_arrayset')){ + function is_arrayset(&$array, $items){ + if (!isset($array)) + return false; + $item = $array; + $arg = func_get_args(); + for($i = 1; $i < count($arg); $i++) { + + $itemindex = $arg[$i]; + if (!isset($item[$itemindex]) || !is_array($item[$itemindex])) + return false; + $item = $item[$itemindex]; + + } + return true; + } +} + function haproxy_compareByName($a, $b) { return strcasecmp($a['name'], $b['name']); } -- cgit v1.2.3 From b5fca0f92f7cd08401571c70810682b31472b781 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Thu, 16 Oct 2014 17:07:37 +0200 Subject: haproxy-devel, bump package version --- pkg_config.10.xml | 2 +- pkg_config.8.xml | 2 +- pkg_config.8.xml.amd64 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 88cd951d..aeb6e037 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -141,7 +141,7 @@ Supports acl's for smart backend switching.]]> http://haproxy.1wt.eu/ Services - 1.5.3 pkg v 0.11 + 1.5.3 pkg v 0.12 Release 2.2 https://packages.pfsense.org/packages/config/haproxy-devel/haproxy.xml diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 40cd348b..91724c55 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -178,7 +178,7 @@ Supports acl's for smart backend switching.]]> http://haproxy.1wt.eu/ Services - 1.5.3 pkg v 0.11 + 1.5.3 pkg v 0.12 Release 2.1 https://packages.pfsense.org/packages/config/haproxy-devel/haproxy.xml diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 8611401d..f37153f9 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -165,7 +165,7 @@ Supports acl's for smart backend switching.]]> http://haproxy.1wt.eu/ Services - 1.5.3 pkg v 0.11 + 1.5.3 pkg v 0.12 Release 2.1 https://packages.pfsense.org/packages/config/haproxy-devel/haproxy.xml -- cgit v1.2.3