From 7b8478c33f7ac74f43bf46d70b7aa6e5e978b56f Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Fri, 14 Jun 2024 02:15:20 +0200 Subject: [PATCH] Fix saving config by set access button This bug has been reported by @ganiuszka in bacularis-app repository. https://github.com/bacularis/bacularis-app/issues/53 --- Web/Pages/Security.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Web/Pages/Security.php b/Web/Pages/Security.php index e027dfa..2505916 100644 --- a/Web/Pages/Security.php +++ b/Web/Pages/Security.php @@ -37,6 +37,7 @@ use Bacularis\Common\Modules\AuthOAuth2; use Bacularis\Common\Modules\AuthBasic; use Bacularis\Common\Modules\AuditLog; +use Bacularis\Common\Modules\Errors\BaculaConfigError; use Bacularis\Common\Modules\Ldap; use Bacularis\Common\Modules\Logging; use Bacularis\Web\Modules\BaculumWebPage; @@ -2805,7 +2806,7 @@ private function setJobResourceAccess($api_host, $jobs) } } - $result = $this->getModule('api')->set([ + $result = $this->getModule('api')->create([ 'config', 'dir', 'Console', @@ -2816,6 +2817,26 @@ private function setJobResourceAccess($api_host, $jobs) if ($result->error === 0) { $this->getModule('api')->set(['console'], ['reload']); + } elseif ($result->error === BaculaConfigError::ERROR_CONFIG_ALREADY_EXISTS) { + // Config exists, so try to update it + $result = $this->getModule('api')->set([ + 'config', + 'dir', + 'Console', + $acls['Name'] + ], [ + 'config' => json_encode($acls) + ], $api_host); + if ($result->error === 0) { + $this->getModule('api')->set(['console'], ['reload']); + } else { + $cb->update( + 'api_host_access_window_error', + $result->output + ); + $cb->show('api_host_access_window_error'); + return ''; + } } else { $cb->update( 'api_host_access_window_error',