Commit 228eaee9 authored by Franco Fichtner's avatar Franco Fichtner

src: remove symlink trickery for /etc/hosts

parent 5337532e
...@@ -1755,7 +1755,7 @@ function services_dnsmasq_configure() ...@@ -1755,7 +1755,7 @@ function services_dnsmasq_configure()
$args = ""; $args = "";
if (isset($config['dnsmasq']['regdhcp'])) { if (isset($config['dnsmasq']['regdhcp'])) {
$args .= " --dhcp-hostsfile={$g['varetc_path']}/hosts "; $args .= " --dhcp-hostsfile=/etc/hosts ";
} }
/* Setup listen port, if non-default */ /* Setup listen port, if non-default */
......
...@@ -306,7 +306,7 @@ function system_hosts_generate() ...@@ -306,7 +306,7 @@ function system_hosts_generate()
sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); 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"); $fd = fopen('/etc/hosts', 'w');
if (!$fd) { if (!$fd) {
log_error("Error: cannot open hosts file in system_hosts_generate().\n"); log_error("Error: cannot open hosts file in system_hosts_generate().\n");
return 1; return 1;
...@@ -333,20 +333,29 @@ function system_dhcpleases_configure() ...@@ -333,20 +333,29 @@ function system_dhcpleases_configure()
|| (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcp']))) { || (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcp']))) {
/* Make sure we do not error out */ /* Make sure we do not error out */
mwexec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db"); 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"); @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"); sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "HUP");
else { } else {
/* To ensure we do not start multiple instances of dhcpleases, perform some clean-up first. */ /* To ensure we do not start multiple instances of dhcpleases, perform some clean-up first. */
if (is_process_running("dhcpleases")) killbyname('dhcpleases');
mwexec('/bin/pkill dhcpleases'); @unlink('/var/run/dhcpleases.pid');
@unlink("{$g['varrun_path']}/dhcpleases.pid"); if (isset($config['unbound']['enable'])) {
if (isset($config['unbound']['enable'])) $dns_pid = 'unbound.pid';
$dns_pid = "unbound.pid"; } else {
else $dns_pid = 'dnsmasq.pid';
$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"); 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 { } else {
sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM");
......
...@@ -169,14 +169,9 @@ if [ ! -L /etc/syslog.conf ]; then ...@@ -169,14 +169,9 @@ if [ ! -L /etc/syslog.conf ]; then
/bin/ln -s /var/etc/syslog.conf /etc/syslog.conf /bin/ln -s /var/etc/syslog.conf /etc/syslog.conf
fi 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 # Remove symlinks that are no longer needed
if [ -L /etc/resolv.conf ]; then rm /etc/resolv.conf; fi 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 # Setup compatibility link for packages that
# have trouble overriding the PREFIX configure # have trouble overriding the PREFIX configure
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment