From b9ed00d53ff739bbb015ef080c070d0f80678dc7 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Wed, 11 Jan 2023 15:25:07 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04660=20Fix=20iTopConfigParserTest=20sett?= =?UTF-8?q?ing=20permissions=20of=20iTop=20config=20file=20Alternative=20m?= =?UTF-8?q?ethod=20to=20restore=20config=20file=20chmod=20cannot=20be=20us?= =?UTF-8?q?ed=20with=20+w=20In=20\Config::WriteToFile=20we=20are=20using?= =?UTF-8?q?=20fopen=20with=20mode=3Dw,=20so=20using=20the=20same=20In=20co?= =?UTF-8?q?nsequence=20we=20are=20not=20modifying=20anymore=20the=20iTop?= =?UTF-8?q?=20config=20file=20permissions=20\o/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unitary-tests/core/iTopConfigParserTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php b/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php index 05c1d2e7e..fd47d9a74 100644 --- a/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php +++ b/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php @@ -44,9 +44,10 @@ class iTopConfigParserTest extends ItopTestCase parent::tearDown(); if ($this->conf_exists) { // restoring config that was in place before the test - @chmod($this->sConfigPath, 0770); // RWX for owner and group, nothing for others : else we will have permission denied ! - rename($this->tmpSavePath, $this->sConfigPath); - @chmod($this->sConfigPath, 0444); + $sBackupConfigFileContent = file_get_contents($this->tmpSavePath); + $hItopConfigFile = @fopen($this->sConfigPath, 'w'); + fwrite($hItopConfigFile, $sBackupConfigFileContent); + fclose($hItopConfigFile); } }