Commit c8a304b0 authored by Franco Fichtner's avatar Franco Fichtner

dns: properly bootstrap unbound root directory

parent b1dab897
...@@ -88,12 +88,23 @@ function unbound_optimization() { ...@@ -88,12 +88,23 @@ function unbound_optimization() {
} }
function bootstrap_unbound_root()
{
global $g;
if (!is_dir($g['unbound_chroot_path'])) {
mkdir($g['unbound_chroot_path']);
chown($g['unbound_chroot_path'], 'unbound');
chgrp($g['unbound_chroot_path'], 'unbound');
}
}
function unbound_generate_config() function unbound_generate_config()
{ {
global $config, $g; global $config, $g;
/* bootstrap unbound root (needed for /var MFS */ // Bootstrap needed for /var MFS
@mkdir($g['unbound_chroot_path']); bootstrap_unbound_root();
// Setup optimization // Setup optimization
$optimization = unbound_optimization(); $optimization = unbound_optimization();
...@@ -361,24 +372,19 @@ function read_hosts() { ...@@ -361,24 +372,19 @@ function read_hosts() {
return $etc_hosts; return $etc_hosts;
} }
function sync_unbound_service() { function sync_unbound_service()
global $config, $g; {
// Configure chroot // Configure chroot
if (!is_dir($g['unbound_chroot_path'])) { bootstrap_unbound_root();
mkdir($g['unbound_chroot_path']);
chown($g['unbound_chroot_path'], "unbound");
chgrp($g['unbound_chroot_path'], "unbound");
}
// Configure our Unbound service // Configure our Unbound service
do_as_unbound_user("unbound-anchor"); do_as_unbound_user("unbound-anchor");
unbound_remote_control_setup(); unbound_remote_control_setup();
unbound_generate_config(); unbound_generate_config();
do_as_unbound_user("start"); do_as_unbound_user("start");
if (is_process_running("unbound")) if (is_process_running('unbound')) {
do_as_unbound_user("restore_cache"); do_as_unbound_user("restore_cache");
}
} }
// Execute commands as the user unbound // Execute commands as the user unbound
...@@ -537,7 +543,7 @@ function unbound_add_host_entries() { ...@@ -537,7 +543,7 @@ function unbound_add_host_entries() {
} }
// Write out entries // Write out entries
@mkdir($g['unbound_chroot_path']); bootstrap_unbound_root();
file_put_contents("{$g['unbound_chroot_path']}/host_entries.conf", $unbound_entries); file_put_contents("{$g['unbound_chroot_path']}/host_entries.conf", $unbound_entries);
} }
...@@ -649,7 +655,7 @@ function unbound_acls_config() { ...@@ -649,7 +655,7 @@ function unbound_acls_config() {
} }
// Write out Access list // Write out Access list
@mkdir($g['unbound_chroot_path']); bootstrap_unbound_root();
file_put_contents("{$g['unbound_chroot_path']}/access_lists.conf", $aclcfg); file_put_contents("{$g['unbound_chroot_path']}/access_lists.conf", $aclcfg);
} }
......
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