From 5cf391c3bbef875590d053f93ee1f1fbe12d9991 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 13 Sep 2022 18:20:35 +0200 Subject: [PATCH 1/3] =?UTF-8?q?N=C2=B05235=20-=20Add=20non=20blocking=20se?= =?UTF-8?q?tup=20check=20:=20is=20tmp=20dir=20is=20writable=20(#301)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setuputils.class.inc.php | 36 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 15c821ece..21dd5cbfe 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -81,16 +81,23 @@ class SetupUtils $aResult = array(); // For log file(s) - if (!is_dir(APPROOT.'log')) - { + if (!is_dir(APPROOT.'log')) { @mkdir(APPROOT.'log'); } self::CheckPhpVersion($aResult); // Check the common directories - $aWritableDirsErrors = self::CheckWritableDirs(array('log', 'env-production', 'env-production-build', 'conf', 'data')); - $aResult = array_merge($aResult, $aWritableDirsErrors); + $aWritableApprootDirsErrors = self::CheckWritableDirs(array('log', 'env-production', 'env-production-build', 'conf', 'data')); + $aResult = array_merge($aResult, $aWritableApprootDirsErrors); + // Check temp dir (N°5235) : as this path isn't under APPROOT we are doing a custom check and not using \SetupUtils::CheckWritableDirs + $sTmpDir = static::GetTmpDir(); + clearstatcache(true, $sTmpDir); + if (is_writable($sTmpDir)) { + $aResult[] = new CheckResult(CheckResult::INFO, "The temp directory is writable by the application."); + } else { + $aResult[] = new CheckResult(CheckResult::ERROR, "The temp directory '".$sTmpDir."' is not writable by the application. Change its permission or use another dir (sys_temp_dir option in php.ini)."); + } $aMandatoryExtensions = array( 'mysqli', @@ -1798,21 +1805,30 @@ JS public static function GetVersionManifest($sInstalledVersion) { - if (preg_match('/^([0-9]+)\./', $sInstalledVersion, $aMatches)) - { + if (preg_match('/^([0-9]+)\./', $sInstalledVersion, $aMatches)) { return APPROOT.'datamodels/'.$aMatches[1].'.x/manifest-'.$sInstalledVersion.'.xml'; } + return false; } + /** + * Check paths relative to APPROOT : is existing, is dir, is writable + * + * @param string[] $aWritableDirs list of dirs to check, relative to APPROOT (for example : `['log','conf','data']`) + * + * @return array full path as key, CheckResult error as value + * + * @uses \is_dir() + * @uses \is_writable() + * @uses \file_exists() + */ public static function CheckWritableDirs($aWritableDirs) { $aNonWritableDirs = array(); - foreach($aWritableDirs as $sDir) - { + foreach ($aWritableDirs as $sDir) { $sFullPath = APPROOT.$sDir; - if (is_dir($sFullPath) && !is_writable($sFullPath)) - { + if (is_dir($sFullPath) && !is_writable($sFullPath)) { $aNonWritableDirs[APPROOT.$sDir] = new CheckResult(CheckResult::ERROR, "The directory '".APPROOT.$sDir."' exists but is not writable for the application."); } else if (file_exists($sFullPath) && !is_dir($sFullPath)) From bdfe3a3b35a876172c6a4334db75ab3621614537 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 13 Sep 2022 18:22:29 +0200 Subject: [PATCH 2/3] =?UTF-8?q?N=C2=B05235=20Tmp=20dir=20setup=20check=20i?= =?UTF-8?q?s=20now=20non=20blocking=20(woops=20previous=20commit=20was=20i?= =?UTF-8?q?ncomplete)=20(#301)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setuputils.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 21dd5cbfe..c8eb6847a 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -96,7 +96,7 @@ class SetupUtils if (is_writable($sTmpDir)) { $aResult[] = new CheckResult(CheckResult::INFO, "The temp directory is writable by the application."); } else { - $aResult[] = new CheckResult(CheckResult::ERROR, "The temp directory '".$sTmpDir."' is not writable by the application. Change its permission or use another dir (sys_temp_dir option in php.ini)."); + $aResult[] = new CheckResult(CheckResult::WARNING, "The temp directory '".$sTmpDir."' is not writable by the application. Change its permission or use another dir (sys_temp_dir option in php.ini)."); } $aMandatoryExtensions = array( From 7512f721e9f61f1901e543f6cabc9a14d13a6ae2 Mon Sep 17 00:00:00 2001 From: xtophe38 <13520055+xtophe38@users.noreply.github.com> Date: Tue, 13 Sep 2022 20:11:38 +0200 Subject: [PATCH 3/3] Setup wizard : use the ITOP_APPLICATION constant instead of hardcoded "iTop" string (#335) * Update wizardsteps.class.inc.php * Done as requested * Fix typo for better readability/genericity Co-authored-by: Molkobain --- setup/wizardsteps.class.inc.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index 81ff1c9c9..b834c2a77 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -658,10 +658,7 @@ EOF ); if ($oMutex->IsLocked()) { - $oPage->add(<<An iTop cron process is being executed on the target database. iTop cron process will be stopped during the setup execution. -HTML - ); + $oPage->add('
'.ITOP_APPLICATION.' cron process is being executed on the target database. '.ITOP_APPLICATION.' cron process will be stopped during the setup execution.
'); } } } @@ -756,8 +753,8 @@ EOF $sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : ''; $oPage->p(''); if ($this->NeedsRgpdConsent()) { - $oPage->add('
iTop software is compliant with the processing of personal data according to the European General Data Protection Regulation (GDPR).

-By installing iTop you agree that some information will be collected by Combodo to help you manage your instances and for statistical purposes. + $oPage->add('
'.ITOP_APPLICATION.' software is compliant with the processing of personal data according to the European General Data Protection Regulation (GDPR).

+By installing '.ITOP_APPLICATION.' you agree that some information will be collected by Combodo to help you manage your instances and for statistical purposes. This data remains anonymous until it is associated to a user account on iTop Hub.

List of collected data available in our Data privacy section.

'); $oPage->add('');