From 6d42d3f9af0d8e54eb7c19e03c153fd3323f7ec6 Mon Sep 17 00:00:00 2001
From: Marcin Krol <hawk@tld-linux.org>
Date: Mon, 4 Jan 2021 21:39:01 +0100
Subject: [PATCH] - drop config path enforcement in PHP

---
 tld.patch   | 54 -----------------------------------------------------
 zabbix.spec |  2 +-
 2 files changed, 1 insertion(+), 55 deletions(-)

diff --git a/tld.patch b/tld.patch
index c5546ed..e4806ab 100644
--- a/tld.patch
+++ b/tld.patch
@@ -176,57 +176,3 @@ diff -ur zabbix-5.0.7.orig/src/zabbix_server/server.c zabbix-5.0.7/src/zabbix_se
  
  	if (NULL == CONFIG_ALERT_SCRIPTS_PATH)
  		CONFIG_ALERT_SCRIPTS_PATH = zbx_strdup(CONFIG_ALERT_SCRIPTS_PATH, DEFAULT_ALERT_SCRIPTS_PATH);
-diff -ur zabbix-5.0.7.orig/ui/include/classes/core/CConfigFile.php zabbix-5.0.7/ui/include/classes/core/CConfigFile.php
---- zabbix-5.0.7.orig/ui/include/classes/core/CConfigFile.php	2020-12-21 10:38:31.000000000 +0100
-+++ zabbix-5.0.7/ui/include/classes/core/CConfigFile.php	2021-01-03 22:57:20.570106105 +0100
-@@ -24,7 +24,7 @@
- 	const CONFIG_NOT_FOUND = 1;
- 	const CONFIG_ERROR = 2;
- 
--	const CONFIG_FILE_PATH = '/conf/zabbix.conf.php';
-+	const CONFIG_FILE_PATH = '/etc/zabbix/web/zabbix.conf.php';
- 
- 	private static $supported_db_types = [
- 		ZBX_DB_MYSQL => true,
-diff -ur zabbix-5.0.7.orig/ui/include/classes/core/ZBase.php zabbix-5.0.7/ui/include/classes/core/ZBase.php
---- zabbix-5.0.7.orig/ui/include/classes/core/ZBase.php	2020-12-21 10:38:31.000000000 +0100
-+++ zabbix-5.0.7/ui/include/classes/core/ZBase.php	2021-01-03 22:57:20.571106105 +0100
-@@ -322,7 +322,7 @@
- 	 * @throws Exception
- 	 */
- 	protected function setMaintenanceMode() {
--		require_once 'conf/maintenance.inc.php';
-+		require_once '/etc/zabbix/web/maintenance.inc.php';
- 
- 		if (defined('ZBX_DENY_GUI_ACCESS')) {
- 			if (!isset($ZBX_GUI_ACCESS_IP_RANGE) || !in_array(CWebUser::getIp(), $ZBX_GUI_ACCESS_IP_RANGE)) {
-@@ -335,7 +335,7 @@
- 	 * Load zabbix config file.
- 	 */
- 	protected function loadConfigFile() {
--		$configFile = $this->getRootDir().CConfigFile::CONFIG_FILE_PATH;
-+		$configFile = CConfigFile::CONFIG_FILE_PATH;
- 		$config = new CConfigFile($configFile);
- 		$this->config = $config->load();
- 	}
-diff -ur zabbix-5.0.7.orig/ui/include/classes/setup/CSetupWizard.php zabbix-5.0.7/ui/include/classes/setup/CSetupWizard.php
---- zabbix-5.0.7.orig/ui/include/classes/setup/CSetupWizard.php	2020-12-21 10:38:31.000000000 +0100
-+++ zabbix-5.0.7/ui/include/classes/setup/CSetupWizard.php	2021-01-03 22:58:00.877106105 +0100
-@@ -425,7 +425,7 @@
- 	private function stage5(): array {
- 		$this->setConfig('ZBX_CONFIG_FILE_CORRECT', true);
- 
--		$config_file_name = APP::getInstance()->getRootDir().CConfigFile::CONFIG_FILE_PATH;
-+		$config_file_name = CConfigFile::CONFIG_FILE_PATH;
- 		$config = new CConfigFile($config_file_name);
- 		$config->config = [
- 			'DB' => [
-@@ -682,7 +682,7 @@
- 				// make zabbix.conf.php downloadable
- 				header('Content-Type: application/x-httpd-php');
- 				header('Content-Disposition: attachment; filename="'.basename(CConfigFile::CONFIG_FILE_PATH).'"');
--				$config = new CConfigFile(APP::getInstance()->getRootDir().CConfigFile::CONFIG_FILE_PATH);
-+				$config = new CConfigFile(CConfigFile::CONFIG_FILE_PATH);
- 				$config->config = [
- 					'DB' => [
- 						'TYPE' => $this->getConfig('DB_TYPE'),
diff --git a/zabbix.spec b/zabbix.spec
index 930f6ef..6493744 100644
--- a/zabbix.spec
+++ b/zabbix.spec
@@ -15,7 +15,7 @@ Summary:	Zabbix - network monitoring software
 Summary(pl.UTF-8):	Zabbix - oprogramowanie do monitorowania sieci
 Name:		zabbix
 Version:	5.0.7
-Release:	0.1
+Release:	0.2
 License:	GPL v2+
 Group:		Networking/Utilities
 Source0:	https://cdn.zabbix.com/zabbix/sources/stable/5.0/%{name}-%{version}.tar.gz
-- 
2.49.0