mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Config file may not exist during unattended setup/backup
This commit is contained in:
@@ -227,7 +227,7 @@ class DBBackup
|
||||
{
|
||||
$sFile = $sTmpFolder.'/config-itop.php';
|
||||
$this->LogInfo("backup: adding resource '$sSourceConfigFile'");
|
||||
copy($sSourceConfigFile, $sFile);
|
||||
@copy($sSourceConfigFile, $sFile); // During unattended install config file may be absent
|
||||
$aRet[] = $sFile;
|
||||
}
|
||||
|
||||
@@ -248,30 +248,33 @@ class DBBackup
|
||||
SetupUtils::copydir($sExtraDir, $sFile);
|
||||
$aRet[] = $sFile;
|
||||
}
|
||||
$aExtraFiles = MetaModel::GetModuleSetting('itop-backup', 'extra_files', []);
|
||||
foreach($aExtraFiles as $sExtraFileOrDir)
|
||||
if (MetaModel::GetConfig() !== null) // During unattended install config file may be absent
|
||||
{
|
||||
if(!file_exists(APPROOT.'/'.$sExtraFileOrDir)) continue; // Ignore non-existing files
|
||||
|
||||
$sExtraFullPath = realpath(APPROOT.'/'.$sExtraFileOrDir);
|
||||
if (strncmp(APPROOT, $sExtraFullPath, strlen(APPROOT)) !== 0)
|
||||
$aExtraFiles = MetaModel::GetModuleSetting('itop-backup', 'extra_files', []);
|
||||
foreach($aExtraFiles as $sExtraFileOrDir)
|
||||
{
|
||||
throw new Exception("Backup: Aborting, resource '$sExtraFileOrDir'. Considered as UNSAFE because not inside the iTop directory.");
|
||||
}
|
||||
if (is_dir($sExtraFullPath))
|
||||
{
|
||||
$sFile = $sTmpFolder.'/'.$sExtraFileOrDir;
|
||||
$this->LogInfo("backup: adding directory '$sExtraFileOrDir'");
|
||||
SetupUtils::copydir($sExtraFullPath, $sFile);
|
||||
$aRet[] = $sFile;
|
||||
}
|
||||
elseif (file_exists($sExtraFullPath))
|
||||
{
|
||||
$sFile = $sTmpFolder.'/'.$sExtraFileOrDir;
|
||||
$this->LogInfo("backup: adding file '$sExtraFileOrDir'");
|
||||
@mkdir(dirname($sFile), 0755, true);
|
||||
copy($sExtraFullPath, $sFile);
|
||||
$aRet[] = $sFile;
|
||||
if(!file_exists(APPROOT.'/'.$sExtraFileOrDir)) continue; // Ignore non-existing files
|
||||
|
||||
$sExtraFullPath = realpath(APPROOT.'/'.$sExtraFileOrDir);
|
||||
if (strncmp(APPROOT, $sExtraFullPath, strlen(APPROOT)) !== 0)
|
||||
{
|
||||
throw new Exception("Backup: Aborting, resource '$sExtraFileOrDir'. Considered as UNSAFE because not inside the iTop directory.");
|
||||
}
|
||||
if (is_dir($sExtraFullPath))
|
||||
{
|
||||
$sFile = $sTmpFolder.'/'.$sExtraFileOrDir;
|
||||
$this->LogInfo("backup: adding directory '$sExtraFileOrDir'");
|
||||
SetupUtils::copydir($sExtraFullPath, $sFile);
|
||||
$aRet[] = $sFile;
|
||||
}
|
||||
elseif (file_exists($sExtraFullPath))
|
||||
{
|
||||
$sFile = $sTmpFolder.'/'.$sExtraFileOrDir;
|
||||
$this->LogInfo("backup: adding file '$sExtraFileOrDir'");
|
||||
@mkdir(dirname($sFile), 0755, true);
|
||||
copy($sExtraFullPath, $sFile);
|
||||
$aRet[] = $sFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$bSkipSQLDumpForTesting)
|
||||
|
||||
Reference in New Issue
Block a user