From aedc25a16e234d264a4577065ee9b8bb93313be4 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 18 Nov 2016 19:01:49 +0100 Subject: [PATCH] dhcp: domain names for IPv6 static maps, tests, alignments --- src/etc/inc/system.inc | 10 +++------- src/www/services_dhcp.php | 9 +++------ src/www/services_dhcpv6.php | 7 ++----- src/www/services_dhcpv6_edit.php | 16 ++++++++++++---- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index f4093afde..f4c0348c1 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -464,16 +464,12 @@ function system_hosts_generate() killbypid('/var/run/dhcpleases.pid', 'TERM', true); $fd = fopen('/etc/hosts', 'w'); - if (!$fd) { - log_error("Error: cannot open hosts file in system_hosts_generate().\n"); - return 1; + if ($fd) { + fwrite($fd, $hosts); + fclose($fd); } - fwrite($fd, $hosts); - fclose($fd); unbound_hosts_generate(); - - return 0; } function system_hostname_configure() diff --git a/src/www/services_dhcp.php b/src/www/services_dhcp.php index d6a21e42a..fb1fe7259 100644 --- a/src/www/services_dhcp.php +++ b/src/www/services_dhcp.php @@ -109,22 +109,19 @@ function reconfigure_dhcpd() killbyname("dhcpd"); dhcp_clean_leases(); system_hosts_generate(); + clear_subsystem_dirty('hosts'); services_dhcpleases_configure(); - if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) { - services_dnsmasq_configure(); - clear_subsystem_dirty('hosts'); - } + if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) { /* XXX we're calling unbound for regdhcpstatic, but restart the whole thing? */ unbound_configure_do(); clear_subsystem_dirty('unbound'); } - services_dhcpd_configure(); + services_dhcpd_configure(); clear_subsystem_dirty('staticmaps'); } - $config_copy_fieldsnames = array('enable', 'staticarp', 'failover_peerip', 'dhcpleaseinlocaltime','descr', 'defaultleasetime', 'maxleasetime', 'gateway', 'domain', 'domainsearchlist', 'denyunknown', 'ddnsdomain', 'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'ddnsupdate', 'mac_allow', 'mac_deny', 'tftp', 'ldap', diff --git a/src/www/services_dhcpv6.php b/src/www/services_dhcpv6.php index 3005f9737..eac11b058 100644 --- a/src/www/services_dhcpv6.php +++ b/src/www/services_dhcpv6.php @@ -34,16 +34,13 @@ require_once("system.inc"); require_once("interfaces.inc"); require_once("services.inc"); - /** * restart dhcp service */ function reconfigure_dhcpd() { - if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) { - services_dnsmasq_configure(); - clear_subsystem_dirty('hosts'); - } + system_hosts_generate(); + clear_subsystem_dirty('hosts'); if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) { /* XXX we're calling unbound for regdhcpstatic, but restart the whole thing? */ diff --git a/src/www/services_dhcpv6_edit.php b/src/www/services_dhcpv6_edit.php index 0d6985a3d..23fca2fc3 100644 --- a/src/www/services_dhcpv6_edit.php +++ b/src/www/services_dhcpv6_edit.php @@ -27,6 +27,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + require_once("guiconfig.inc"); require_once("interfaces.inc"); require_once("services.inc"); @@ -36,7 +37,6 @@ function staticmapcmp($a, $b) return ipcmp($a['ipaddrv6'], $b['ipaddrv6']); } - if ($_SERVER['REQUEST_METHOD'] === 'GET') { // handle identifiers and action if (!empty($_GET['if']) && !empty($config['interfaces'][$_GET['if']])) { @@ -51,7 +51,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // read form data $pconfig = array(); - $config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr'); + $config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr', 'domain'); foreach ($config_copy_fieldnames as $fieldname) { if (isset($if) && isset($id) && isset($config['dhcpdv6'][$if]['staticmap'][$id][$fieldname])) { $pconfig[$fieldname] = $config['dhcpdv6'][$if]['staticmap'][$id][$fieldname]; @@ -61,7 +61,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig[$fieldname] = null; } } - } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors = array(); $pconfig = $_POST; @@ -118,7 +117,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } if (count($input_errors) == 0) { $mapent = array(); - $config_copy_fieldnames = array('duid', 'ipaddrv6', 'hostname', 'descr', 'filename', 'rootpath'); + $config_copy_fieldnames = array('duid', 'ipaddrv6', 'hostname', 'descr', 'filename', 'rootpath', 'domain'); foreach ($config_copy_fieldnames as $fieldname) { if (!empty($pconfig[$fieldname])) { $mapent[$fieldname] = $pconfig[$fieldname]; @@ -207,6 +206,15 @@ include("head.inc"); + + + + + + +