From 1ca149fdcc2e0cb0722fa203bdba42133cea0123 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 28 Jun 2022 14:15:32 +0200 Subject: [PATCH] dhcp: remove ddnsupdate static mapping switch From a top-down perspective it only makes sense if ddns is enabled globally, but in this case someone went copy+paste a bit too much. Since now we force ddns-hostname from global state it makes sense to tie the static override to this as well instead of making a sub- switch for global functionality for an optional field to smoothen the expected result. If this override is actually useful is another question entirely. --- src/etc/inc/plugins.inc.d/dhcpd.inc | 4 ++-- src/www/services_dhcp_edit.php | 24 ++++++------------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/dhcpd.inc b/src/etc/inc/plugins.inc.d/dhcpd.inc index ad354a76e..e671c6791 100644 --- a/src/etc/inc/plugins.inc.d/dhcpd.inc +++ b/src/etc/inc/plugins.inc.d/dhcpd.inc @@ -1144,8 +1144,8 @@ EOD; $smdnscfg .= " option domain-search \"" . join("\",\"", preg_split("/[ ;]+/", $sm['domainsearchlist'])) . "\";\n"; } - if (isset($sm['ddnsupdate'])) { - if (($sm['ddnsdomain'] != '') && ($sm['ddnsdomain'] != $dhcpifconf['ddnsdomain'])) { + if ($need_ddns_updates) { + if (!empty($sm['ddnsdomain']) && ($sm['ddnsdomain'] != $dhcpifconf['ddnsdomain'])) { $smdnscfg .= " ddns-domainname \"{$sm['ddnsdomain']}\";\n"; } } diff --git a/src/www/services_dhcp_edit.php b/src/www/services_dhcp_edit.php index 6f2fd466f..c610c2a67 100644 --- a/src/www/services_dhcp_edit.php +++ b/src/www/services_dhcp_edit.php @@ -46,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = array(); $config_copy_fieldnames = array('mac', 'cid', 'hostname', 'filename', 'rootpath', 'descr', 'arp_table_static_entry', 'defaultleasetime', 'maxleasetime', 'gateway', 'domain', 'domainsearchlist', 'winsserver', 'dnsserver', 'ddnsdomain', - 'ddnsupdate', 'ntpserver', 'tftp', 'bootfilename', 'ipaddr', 'winsserver', 'dnsserver'); + 'ntpserver', 'tftp', 'bootfilename', 'ipaddr', 'winsserver', 'dnsserver'); foreach ($config_copy_fieldnames as $fieldname) { if (isset($if) && isset($id) && isset($config['dhcpd'][$if]['staticmap'][$id][$fieldname])) { $pconfig[$fieldname] = $config['dhcpd'][$if]['staticmap'][$id][$fieldname]; @@ -216,7 +216,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $mapent = array(); $config_copy_fieldnames = array('mac', 'cid', 'ipaddr', 'hostname', 'descr', 'filename', 'rootpath', 'arp_table_static_entry', 'defaultleasetime', 'maxleasetime', 'gateway', 'domain', 'domainsearchlist', - 'ddnsdomain', 'ddnsupdate', 'tftp', 'bootfilename', 'winsserver', 'dnsserver'); + 'ddnsdomain', 'tftp', 'bootfilename', 'winsserver', 'dnsserver'); foreach ($config_copy_fieldnames as $fieldname) { if (!empty($pconfig[$fieldname])) { @@ -226,7 +226,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // boolean $mapent['arp_table_static_entry'] = !empty($pconfig['arp_table_static_entry']); - $mapent['ddnsupdate'] = !empty($pconfig['ddnsupdate']); // arrays $mapent['winsserver'] = array(); @@ -284,11 +283,6 @@ include("head.inc");