Skip to content

Commit

Permalink
dns: properly bootstrap unbound root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Aug 6, 2015
1 parent b1dab89 commit c8a304b
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/etc/inc/unbound.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
global $config, $g;

/* bootstrap unbound root (needed for /var MFS */
@mkdir($g['unbound_chroot_path']);
// Bootstrap needed for /var MFS
bootstrap_unbound_root();

// Setup optimization
$optimization = unbound_optimization();
Expand Down Expand Up @@ -361,24 +372,19 @@ function read_hosts() {
return $etc_hosts;
}

function sync_unbound_service() {
global $config, $g;

function sync_unbound_service()
{
// Configure chroot
if (!is_dir($g['unbound_chroot_path'])) {
mkdir($g['unbound_chroot_path']);
chown($g['unbound_chroot_path'], "unbound");
chgrp($g['unbound_chroot_path'], "unbound");
}
bootstrap_unbound_root();

// Configure our Unbound service
do_as_unbound_user("unbound-anchor");
unbound_remote_control_setup();
unbound_generate_config();
do_as_unbound_user("start");
if (is_process_running("unbound"))
if (is_process_running('unbound')) {
do_as_unbound_user("restore_cache");

}
}

// Execute commands as the user unbound
Expand Down Expand Up @@ -537,7 +543,7 @@ function unbound_add_host_entries() {
}

// Write out entries
@mkdir($g['unbound_chroot_path']);
bootstrap_unbound_root();
file_put_contents("{$g['unbound_chroot_path']}/host_entries.conf", $unbound_entries);
}

Expand Down Expand Up @@ -649,7 +655,7 @@ function unbound_acls_config() {
}

// Write out Access list
@mkdir($g['unbound_chroot_path']);
bootstrap_unbound_root();
file_put_contents("{$g['unbound_chroot_path']}/access_lists.conf", $aclcfg);
}

Expand Down

0 comments on commit c8a304b

Please sign in to comment.