diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2008-02-03 00:55:32 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2008-02-03 00:55:32 +0000 |
commit | 96acb6e6c1a31ef688048d4c730c29dd860d62da (patch) | |
tree | 67a881fd8f24fc14a3ba5a4720cb6fc90342f78e /packages/openbgpd/openbgpd.inc | |
parent | 12ec2cb4f8d80d9bfe149dbb687b7b27f0d92cea (diff) | |
download | pfsense-packages-96acb6e6c1a31ef688048d4c730c29dd860d62da.tar.gz pfsense-packages-96acb6e6c1a31ef688048d4c730c29dd860d62da.tar.bz2 pfsense-packages-96acb6e6c1a31ef688048d4c730c29dd860d62da.zip |
* Do not foreach through non-arrays
Diffstat (limited to 'packages/openbgpd/openbgpd.inc')
-rw-r--r-- | packages/openbgpd/openbgpd.inc | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/packages/openbgpd/openbgpd.inc b/packages/openbgpd/openbgpd.inc index 14a9a28d..70b725c6 100644 --- a/packages/openbgpd/openbgpd.inc +++ b/packages/openbgpd/openbgpd.inc @@ -34,11 +34,13 @@ function openbgpd_install_conf() { conf_mount_rw(); - $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; - $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; - $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; - $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; - + if($config['installedpackages']['openbgpd']['config']) { + $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; + $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; + $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; + $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; + } + $fd = fopen("/usr/local/etc/bgpd.conf", "w"); $conffile = ""; @@ -70,14 +72,16 @@ function openbgpd_install_conf() { foreach($openbgpd_groups as $group) { $conffile .= "group \"{$group['name']}\" {\n"; $conffile .= " remote-as {$group['remoteas']}\n"; - foreach($openbgpd_neighbors as $neighbor) { - if($neighbor['groupname'] == $group['name']) { - $conffile .= " neighbor {$neighbor['neighbor']} {\n"; - $conffile .= " descr \"{$neighbor['descr']}\"\n"; - foreach($neighbor['row'] as $row) { - $conffile .= " {$row['paramaters']} {$row['parmvalue']} \n"; - } - $conffile .= " }\n"; + if(is_array($openbgpd_neighbors)) { + foreach($openbgpd_neighbors as $neighbor) { + if($neighbor['groupname'] == $group['name']) { + $conffile .= " neighbor {$neighbor['neighbor']} {\n"; + $conffile .= " descr \"{$neighbor['descr']}\"\n"; + foreach($neighbor['row'] as $row) { + $conffile .= " {$row['paramaters']} {$row['parmvalue']} \n"; + } + $conffile .= " }\n"; + } } } $conffile .= "}\n"; @@ -148,10 +152,12 @@ function deinstall_openbgpd() { function check_group_usage($groupname) { global $config, $g; - $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; - $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; - $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; - $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; + if($config['installedpackages']['openbgpd']['config']) { + $openbgpd_conf = &$config['installedpackages']['openbgpd']['config'][0]; + $openbgpd_rows = &$config['installedpackages']['openbgpd']['config'][0]['row']; + $openbgpd_groups = &$config['installedpackages']['openbgpdgroups']['config']; + $openbgpd_neighbors = &$config['installedpackages']['openbgpdneighbors']['config']; + } if(is_array($openbgpd_groups)) { foreach($openbgpd_groups as $group) { foreach($openbgpd_neighbors as $neighbor) { |