summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-05-01 13:09:04 -0300
committerRenato Botelho <garga@FreeBSD.org>2013-05-01 13:09:04 -0300
commitea1aca1326c79d5c819ec7c22c068b1c63074828 (patch)
tree3ea3afab2142ad6a1a474d00f9cd122272b6631c /etc/inc
parentdfe2769c46d6f1a5fb29218e902901ea3ea080cb (diff)
downloadpfsense-ea1aca1326c79d5c819ec7c22c068b1c63074828.zip
pfsense-ea1aca1326c79d5c819ec7c22c068b1c63074828.tar.gz
Fix dnsmasq host overrides and dhcp integration
. Do not execute following actions when dnsmasq is disabled: . Add host overrides to /etc/hosts . Register DHCP leases in DNS Forwarder . Register DHCP static mappings in DNS forwarder It should fix issue reported at following forum post: http://forum.pfsense.org/index.php?topic=58871
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/system.inc74
1 files changed, 37 insertions, 37 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index f1cb84c..43c9a9f 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -233,11 +233,6 @@ function system_hosts_generate() {
$syscfg = $config['system'];
$dnsmasqcfg = $config['dnsmasq'];
- if (!is_array($dnsmasqcfg['hosts'])) {
- $dnsmasqcfg['hosts'] = array();
- }
- $hostscfg = $dnsmasqcfg['hosts'];
-
$hosts = "127.0.0.1 localhost localhost.{$syscfg['domain']}\n";
$lhosts = "";
$dhosts = "";
@@ -259,39 +254,44 @@ function system_hosts_generate() {
}
}
- foreach ($hostscfg as $host) {
- if ($host['host'])
- $lhosts .= "{$host['ip']} {$host['host']}.{$host['domain']} {$host['host']}\n";
- else
- $lhosts .= "{$host['ip']} {$host['domain']}\n";
- if (!is_array($host['aliases']) || !is_array($host['aliases']['item']))
- continue;
- foreach ($host['aliases']['item'] as $alias) {
- if ($alias['host'])
- $lhosts .= "{$host['ip']} {$alias['host']}.{$alias['domain']} {$alias['host']}\n";
+ if (isset($dnsmasq['enable'])) {
+ if (!is_array($dnsmasqcfg['hosts']))
+ $dnsmasqcfg['hosts'] = array();
+
+ foreach ($dnsmasqcfg['hosts'] as $host) {
+ if ($host['host'])
+ $lhosts .= "{$host['ip']} {$host['host']}.{$host['domain']} {$host['host']}\n";
else
- $lhosts .= "{$host['ip']} {$alias['domain']}\n";
+ $lhosts .= "{$host['ip']} {$host['domain']}\n";
+ if (!is_array($host['aliases']) || !is_array($host['aliases']['item']))
+ continue;
+ foreach ($host['aliases']['item'] as $alias) {
+ if ($alias['host'])
+ $lhosts .= "{$host['ip']} {$alias['host']}.{$alias['domain']} {$alias['host']}\n";
+ else
+ $lhosts .= "{$host['ip']} {$alias['domain']}\n";
+ }
+ }
+ if (isset($dnsmasqcfg['regdhcpstatic']) && is_array($config['dhcpd'])) {
+ foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf)
+ if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
+ foreach ($dhcpifconf['staticmap'] as $host)
+ if ($host['ipaddr'] && $host['hostname'])
+ $dhosts .= "{$host['ipaddr']} {$host['hostname']}.{$syscfg['domain']} {$host['hostname']}\n";
+ }
+ if (isset($dnsmasqcfg['regdhcpstatic']) && is_array($config['dhcpdv6'])) {
+ foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf)
+ if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
+ foreach ($dhcpifconf['staticmap'] as $host)
+ if ($host['ipaddrv6'] && $host['hostname'])
+ $dhosts .= "{$host['ipaddrv6']} {$host['hostname']}.{$syscfg['domain']} {$host['hostname']}\n";
}
- }
- if (isset($dnsmasqcfg['regdhcpstatic']) && is_array($config['dhcpd'])) {
- foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf)
- if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
- foreach ($dhcpifconf['staticmap'] as $host)
- if ($host['ipaddr'] && $host['hostname'])
- $dhosts .= "{$host['ipaddr']} {$host['hostname']}.{$syscfg['domain']} {$host['hostname']}\n";
- }
- if (isset($dnsmasqcfg['regdhcpstatic']) && is_array($config['dhcpdv6'])) {
- foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf)
- if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
- foreach ($dhcpifconf['staticmap'] as $host)
- if ($host['ipaddrv6'] && $host['hostname'])
- $dhosts .= "{$host['ipaddrv6']} {$host['hostname']}.{$syscfg['domain']} {$host['hostname']}\n";
- }
- if (isset($dnsmasqcfg['dhcpfirst']))
- $hosts .= $dhosts . $lhosts;
- else
- $hosts .= $lhosts . $dhosts;
+ if (isset($dnsmasqcfg['dhcpfirst']))
+ $hosts .= $dhosts . $lhosts;
+ else
+ $hosts .= $lhosts . $dhosts;
+ }
/*
* Do not remove this because dhcpleases monitors with kqueue it needs to be
@@ -299,7 +299,7 @@ function system_hosts_generate() {
*/
if (file_exists("{$g['varrun_path']}/dhcpleases.pid")) {
sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM");
- @unlink("{$g['varrun_path']}/dhcpleases.pid");
+ @unlink("{$g['varrun_path']}/dhcpleases.pid");
}
$fd = fopen("{$g['varetc_path']}/hosts", "w");
if (!$fd) {
@@ -320,7 +320,7 @@ function system_dhcpleases_configure() {
if ($g['platform'] == 'jail')
return;
/* Start the monitoring process for dynamic dhcpclients. */
- if (isset($config['dnsmasq']['regdhcp'])) {
+ if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcp'])) {
/* Make sure we do not error out */
mwexec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db");
if (!file_exists("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"))
OpenPOWER on IntegriCloud