diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 42214b574..f1f7af3e1 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -1755,7 +1755,7 @@ function services_dnsmasq_configure() $args = ""; if (isset($config['dnsmasq']['regdhcp'])) { - $args .= " --dhcp-hostsfile={$g['varetc_path']}/hosts "; + $args .= " --dhcp-hostsfile=/etc/hosts "; } /* Setup listen port, if non-default */ diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index a98ab176d..0a895ca3d 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -306,7 +306,7 @@ function system_hosts_generate() sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); @unlink("{$g['varrun_path']}/dhcpleases.pid"); } - $fd = fopen("{$g['varetc_path']}/hosts", "w"); + $fd = fopen('/etc/hosts', 'w'); if (!$fd) { log_error("Error: cannot open hosts file in system_hosts_generate().\n"); return 1; @@ -333,20 +333,29 @@ function system_dhcpleases_configure() || (isset($config['unbound']['enable']) && isset($config['unbound']['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")) + if (!file_exists("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases")) { @touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"); - if (isvalidpid("{$g['varrun_path']}/dhcpleases.pid")) + } + if (isvalidpid("{$g['varrun_path']}/dhcpleases.pid")) { sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "HUP"); - else { + } else { /* To ensure we do not start multiple instances of dhcpleases, perform some clean-up first. */ - if (is_process_running("dhcpleases")) - mwexec('/bin/pkill dhcpleases'); - @unlink("{$g['varrun_path']}/dhcpleases.pid"); - if (isset($config['unbound']['enable'])) - $dns_pid = "unbound.pid"; - else - $dns_pid = "dnsmasq.pid"; - mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/{$dns_pid} -h {$g['varetc_path']}/hosts"); + killbyname('dhcpleases'); + @unlink('/var/run/dhcpleases.pid'); + if (isset($config['unbound']['enable'])) { + $dns_pid = 'unbound.pid'; + } else { + $dns_pid = 'dnsmasq.pid'; + } + mwexecf( + '/usr/local/sbin/dhcpleases -l %s -d %s -p %s -h %s', + array( + "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases", + $config['system']['domain'], + "/var/run/{$dns_pid}", + '/etc/hosts' + ) + ); } } else { sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); diff --git a/src/etc/rc b/src/etc/rc index 0e648c7cd..876abf1f7 100755 --- a/src/etc/rc +++ b/src/etc/rc @@ -169,14 +169,9 @@ if [ ! -L /etc/syslog.conf ]; then /bin/ln -s /var/etc/syslog.conf /etc/syslog.conf fi -# Repair symlinks if they are broken -if [ ! -L /etc/hosts ]; then - /bin/rm -rf /etc/hosts - /bin/ln -s /var/etc/hosts /etc/hosts -fi - # Remove symlinks that are no longer needed if [ -L /etc/resolv.conf ]; then rm /etc/resolv.conf; fi +if [ -L /etc/hosts ]; then /bin/rm /etc/hosts; fi # Setup compatibility link for packages that # have trouble overriding the PREFIX configure