From c05c16a5163c590bae452b2e3be82bfb446ac277 Mon Sep 17 00:00:00 2001 From: Miraty Date: Wed, 3 May 2023 01:38:50 +0200 Subject: [PATCH] --blocking for knotc everywhere --- fn/dns.php | 20 ++++++++++---------- fn/ns.php | 2 +- pg-act/ns/edit.php | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fn/dns.php b/fn/dns.php index 139cd70..b95f73c 100644 --- a/fn/dns.php +++ b/fn/dns.php @@ -16,21 +16,21 @@ function parseZoneFile($zone_content, $types, $filter_domain = false) { } function knotcConfExec($cmds) { - exec(CONF['dns']['knotc_path'] . ' conf-begin', $output['begin'], $code['begin']); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 conf-begin', $output['begin'], $code['begin']); if ($code['begin'] !== 0) output(500, 'knotcConfExec: knotc failed with exit code ' . $code['begin'] . ': ' . $output['begin'][0] . '.'); foreach ($cmds as $cmd) { - exec(CONF['dns']['knotc_path'] . ' conf-' . $cmd, $output['op'], $code['op']); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 conf-' . $cmd, $output['op'], $code['op']); if ($code['op'] !== 0) { - exec(CONF['dns']['knotc_path'] . ' conf-abort'); + exec(CONF['dns']['knotc_path'] . ' --blocking conf-abort'); output(500, 'knotcConfExec: knotc failed with exit code ' . $code['op'] . ': ' . $output['op'][0] . '.'); } } - exec(CONF['dns']['knotc_path'] . ' conf-commit', $output['commit'], $code['commit']); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 conf-commit', $output['commit'], $code['commit']); if ($code['commit'] !== 0) { - exec(CONF['dns']['knotc_path'] . ' conf-abort'); + exec(CONF['dns']['knotc_path'] . ' --blocking conf-abort'); output(500, 'knotcConfExec: knotc failed with exit code ' . $code['commit'] . ': ' . $output['commit'][0] . '.'); } } @@ -38,19 +38,19 @@ function knotcConfExec($cmds) { function knotcZoneExec($zone, $cmd, $action = NULL) { $action = checkAction($action ?? $_POST['action']); - exec(CONF['dns']['knotc_path'] . ' zone-begin ' . $zone, $output['begin'], $code['begin']); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-begin ' . $zone, $output['begin'], $code['begin']); if ($code['begin'] !== 0) output(500, 'knotcZoneExec: knotc failed with exit code ' . $code['begin'] . ': ' . $output['begin'][0] . '.'); - exec(CONF['dns']['knotc_path'] . ' zone-' . $action . 'set ' . $zone . ' ' . implode(' ', $cmd), $output['op'], $code['op']); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-' . $action . 'set ' . $zone . ' ' . implode(' ', $cmd), $output['op'], $code['op']); if ($code['op'] !== 0) { - exec(CONF['dns']['knotc_path'] . ' zone-abort ' . $zone); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-abort ' . $zone); output(500, 'knotcZoneExec: knotc failed with exit code ' . $code['op'] . ': ' . $output['op'][0] . '.'); } - exec(CONF['dns']['knotc_path'] . ' zone-commit ' . $zone, $output['commit'], $code['commit']); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-commit ' . $zone, $output['commit'], $code['commit']); if ($code['commit'] !== 0) { - exec(CONF['dns']['knotc_path'] . ' zone-abort ' . $zone); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-abort ' . $zone); output(500, 'knotcZoneExec: knotc failed with exit code ' . $code['commit'] . ': ' . $output['commit'][0] . '.'); } } diff --git a/fn/ns.php b/fn/ns.php index f521e7a..9ee5b8e 100644 --- a/fn/ns.php +++ b/fn/ns.php @@ -59,7 +59,7 @@ function nsCheckZonePossession($zone) { function nsDeleteZone($zone) { // Delete zone data - exec(CONF['dns']['knotc_path'] . ' --force zone-purge ' . $zone, result_code: $code); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 --force zone-purge ' . $zone, result_code: $code); if ($code !== 0) output(500, 'Failed to purge zone data.'); diff --git a/pg-act/ns/edit.php b/pg-act/ns/edit.php index cfb3eb9..74db8a0 100644 --- a/pg-act/ns/edit.php +++ b/pg-act/ns/edit.php @@ -39,22 +39,22 @@ if (isset($_POST['zone-content'])) { // Update zone ratelimit(); - exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 10 zone-freeze ' . $_POST['zone'], $output, $return_code); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-freeze ' . $_POST['zone'], $output, $return_code); if ($return_code !== 0) output(500, 'Failed to freeze zone file.', $output); - exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 10 zone-flush ' . $_POST['zone'], $output, $return_code); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-flush ' . $_POST['zone'], $output, $return_code); if ($return_code !== 0) output(500, 'Failed to flush zone file.', $output); if (file_put_contents(CONF['ns']['knot_zones_path'] . '/' . $_POST['zone'] . 'zone', $new_zone_content) === false) output(500, 'Failed to write zone file.'); - exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 10 zone-reload ' . $_POST['zone'], $output, $return_code); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-reload ' . $_POST['zone'], $output, $return_code); if ($return_code !== 0) output(500, 'Failed to reload zone file.', $output); - exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 10 zone-thaw ' . $_POST['zone'], $output, $return_code); + exec(CONF['dns']['knotc_path'] . ' --blocking --timeout 3 zone-thaw ' . $_POST['zone'], $output, $return_code); if ($return_code !== 0) output(500, 'Failed to thaw zone file.', $output);