diff options
author | Renato Botelho <renato@netgate.com> | 2017-01-11 14:30:44 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-11 14:47:21 -0200 |
commit | 828970429bcc2a9cb01fcf79bf3fc1c156ef1b09 (patch) | |
tree | a48006d3b8f951ac3c88ea511c97f15416fa10a1 /src/etc | |
parent | 829f3ca3ae7250b6d3c4dee61e32d0b2051c5252 (diff) | |
download | pfsense-828970429bcc2a9cb01fcf79bf3fc1c156ef1b09.zip pfsense-828970429bcc2a9cb01fcf79bf3fc1c156ef1b09.tar.gz |
Ticket #6712: Create system_hosts_entries()
This function will return an array all items to be added to /etc/hosts.
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/system.inc | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 86a1796..b387814 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -526,6 +526,26 @@ function system_hosts_dhcpd_entries() { return $hosts; } +/* Concatenate local, dnsmasq/unbound and dhcpd/dhcpdv6 hosts entries */ +function system_hosts_entries($dnscfg) { + $local = system_hosts_local_entries(); + + $dns = array(); + $dhcpd = array(); + if (isset($dnscfg['enable'])) { + $dns = system_hosts_override_entries($dnscfg); + if (isset($dnscfg['regdhcpstatic'])) { + $dhcpd = system_hosts_dhcpd_entries(); + } + } + + if (isset($dnscfg['dhcpfirst'])) { + return array_merge($local, $dns, $dhcpd); + } else { + return array_merge($local, $dhcpd, $dns); + } +} + function system_hosts_generate() { global $config, $g; if (isset($config['system']['developerspew'])) { @@ -546,7 +566,7 @@ function system_hosts_generate() { $lhosts = ""; $dhosts = ""; - $hosts_array = system_hosts_local_entries(); + $hosts_array = system_hosts_entries($dnsmasqcfg); foreach ($hosts_array as $host) { $hosts .= "{$host['ipaddr']}\t{$host['fqdn']}"; if (!empty($host['name'])) { @@ -556,29 +576,6 @@ function system_hosts_generate() { } unset($hosts_array); - if (isset($dnsmasqcfg['enable'])) { - $hosts_array = system_hosts_override_entries($dnsmasqcfg); - foreach ($hosts_array as $host) { - $lhosts .= "{$host['ipaddr']}\t{$host['fqdn']}\n"; - } - unset($hosts_array); - - if (isset($dnsmasqcfg['regdhcpstatic'])) { - $hosts_array = system_hosts_dhcpd_entries(); - foreach ($hosts_array as $host) { - $dhosts .= "{$host['ipaddr']}\t" . - "{$host['fqdn']}\n"; - } - unset($hosts_array); - } - - if (isset($dnsmasqcfg['dhcpfirst'])) { - $hosts .= $dhosts . $lhosts; - } else { - $hosts .= $lhosts . $dhosts; - } - } - $fd = fopen("{$g['varetc_path']}/hosts", "w"); if (!$fd) { log_error(gettext( |