From f6db0eeffba7aedc4fb2687730509c52dba616d5 Mon Sep 17 00:00:00 2001 From: Chris Buechler Date: Sun, 4 Nov 2007 22:06:01 +0000 Subject: [PATCH] Do not allow DHCP server to be enabled when DHCP relay is enabled, and vice versa Ticket #1488 --- usr/local/www/services_dhcp.php | 28 +++++++++++++++++++++++++++ usr/local/www/services_dhcp_relay.php | 7 ++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php index 0f09b4eda9..9883966527 100755 --- a/usr/local/www/services_dhcp.php +++ b/usr/local/www/services_dhcp.php @@ -81,6 +81,25 @@ $pconfig['netmask'] = $config['dhcpd'][$if]['netmask']; $ifcfg = $config['interfaces'][$if]; +/* set the enabled flag which will tell us if DHCP relay is enabled + * on any interface. We will use this to disable DHCP server since + * the two are not compatible with each other. + */ + +$dhcrelay_enabled = false; +$dhcrelaycfg = $config['dhcrelay']; + +if(is_array($dhcrelaycfg)) { + foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) { + if (isset($dhcrelayifconf['enable']) && + (($dhcrelayif == "lan") || + (isset($config['interfaces'][$dhcrelayif]['enable']) && + $config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge'])))) + $dhcrelay_enabled = true; + } +} + + if (!is_array($config['dhcpd'][$if]['staticmap'])) { $config['dhcpd'][$if]['staticmap'] = array(); } @@ -310,6 +329,15 @@ function show_netboot_config() {
+"; + echo ""; + exit; + } +?>

You must apply the changes in order for them to take effect.");?>
diff --git a/usr/local/www/services_dhcp_relay.php b/usr/local/www/services_dhcp_relay.php index 74a114ace8..9db68aa68a 100755 --- a/usr/local/www/services_dhcp_relay.php +++ b/usr/local/www/services_dhcp_relay.php @@ -88,8 +88,9 @@ $ifcfg = $config['interfaces'][$if]; * the two are not compatible with each other. */ $dhcpd_enabled = false; -foreach($config['dhcpd'] as $dhcp) - if($dhcp['enable']) $dhcpd_enabled = true; +foreach($config['dhcpd'] as $dhcp) { + if(isset($dhcp['enable'])) $dhcpd_enabled = true; +} if ($_POST) { @@ -179,7 +180,7 @@ function enable_change(enable_over) { "; echo "";