From a30180d868a9977e7004f8610b3ee9713d04dd91 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Wed, 30 Jun 2021 13:17:18 +0200 Subject: [PATCH] webui: check major version compatibility between webui and DIR To ensure the installed WEBUI and DIR have the same version because of compatibility reasons, this commit introduces a version check at login time which provides an error message if versions do not match. Fixes #0000871: UI will not load complete --- .../src/Auth/Controller/AuthController.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/webui/module/Auth/src/Auth/Controller/AuthController.php b/webui/module/Auth/src/Auth/Controller/AuthController.php index 3a143f4e9f0..022da7fa755 100644 --- a/webui/module/Auth/src/Auth/Controller/AuthController.php +++ b/webui/module/Auth/src/Auth/Controller/AuthController.php @@ -142,6 +142,12 @@ public function loginAction() return $this->createNewLoginForm($form, $multi_dird_env, $apicheck, $this->bsock); } + $versioncheck = $this->checkVersionCompatibilityDIRD(); + + if($versioncheck !== true) { + return $this->createNewLoginForm($form, $multi_dird_env, $versioncheck, $this->bsock); + } + $aclcheck = $this->checkACLStatusDIRD(); if(!$aclcheck) { @@ -208,6 +214,25 @@ private function createNewLoginForm($form, $multi_dird_env = null, $err_msg = nu ); } + /** + * DIRD version compatibility check + * + * @return mixed + */ + private function checkVersionCompatibilityDIRD() { + include 'version.php'; // provides bareos_full_version (installed ui version) + $dird_version_array = $this->getDirectorModel()->getDirectorVersion($this->bsock); + $dird_version = $dird_version_array['version']; + // compare major version + $dird_major_version = explode('.', $dird_version)[0]; + $ui_major_version = explode('.', $bareos_full_version)[0]; + if($dird_major_version !== $ui_major_version) { + $err_msg = 'Error: Bareos WebUI ('.$bareos_full_version.') requires a Director of the same major release ('.$dird_major_version.'). The Director version is '.$dird_version.'.'; + return $err_msg; + } + return true; + } + /** * DIRD API check *