diff --git a/core/cmdbsource.class.inc.php b/core/cmdbsource.class.inc.php
index 9f580d1ae..502892d6c 100644
--- a/core/cmdbsource.class.inc.php
+++ b/core/cmdbsource.class.inc.php
@@ -176,7 +176,9 @@ class CMDBSource
$sServer = null;
$iPort = null;
- self::InitServerAndPort($sServer, $iPort);
+ $bSslEnabled = self::IsDbConnectionUsingSsl($sSSLKey, $sSSLCert, $sSSLCA);
+ self::InitServerAndPort($sServer, $iPort, $bSslEnabled);
+
$iFlags = null;
// *some* errors (like connection errors) will throw mysqli_sql_exception instead of generating warnings printed to the output
@@ -188,7 +190,7 @@ class CMDBSource
$oMysqli = new mysqli();
$oMysqli->init();
- if (!empty($sSSLKey) && !empty($sSSLCert) && !empty($sSSLCA))
+ if ($bSslEnabled)
{
$iFlags = MYSQLI_CLIENT_SSL;
$oMysqli->ssl_set($sSSLKey, $sSSLCert, $sSSLCA, $sSSLCaPath, $sSSLCipher);
@@ -224,8 +226,9 @@ class CMDBSource
*
* @param string $sServer
* @param int $iPort
+ * @param boolean $bSslEnabled
*/
- private static function InitServerAndPort(&$sServer, &$iPort)
+ private static function InitServerAndPort(&$sServer, &$iPort, $bSslEnabled)
{
$aConnectInfo = explode(':', self::$m_sDBHost);
if (count($aConnectInfo) > 1)
@@ -240,7 +243,7 @@ class CMDBSource
$iPort = null;
}
- if (!empty(self::$m_sDBSSLKey) && !empty(self::$m_sDBSSLCert) && !empty(self::$m_sDBSSLCA))
+ if ($bSslEnabled)
{
// use persistent connexions to limit TLS overhead
// see http://php.net/manual/en/mysqli.persistconns.php
@@ -248,6 +251,32 @@ class CMDBSource
}
}
+ /**
+ * @param \Config $oConfig
+ *
+ * @return boolean
+ */
+ public static function IsDbConnectionInConfigUsingSsl($oConfig)
+ {
+ $sSSLKey = $oConfig->Get('db_ssl.key');
+ $sSSLCert = $oConfig->Get('db_ssl.cert');
+ $sSSLCA = $oConfig->Get('db_ssl.ca');
+
+ return self::IsDbConnectionUsingSsl($sSSLKey, $sSSLCert, $sSSLCA);
+ }
+
+ /**
+ * @param string $sSSLKey
+ * @param string $sSSLCert
+ * @param string $sSSLCA
+ *
+ * @return bool
+ */
+ public static function IsDbConnectionUsingSsl($sSSLKey, $sSSLCert, $sSSLCA)
+ {
+ return (!empty($sSSLKey) && !empty($sSSLCert) && !empty($sSSLCA));
+ }
+
public static function SetCharacterSet($sCharset = 'utf8', $sCollation = 'utf8_general_ci')
{
if (strlen($sCharset) > 0)
diff --git a/core/config.class.inc.php b/core/config.class.inc.php
index 3dca9b526..660260ad1 100644
--- a/core/config.class.inc.php
+++ b/core/config.class.inc.php
@@ -148,24 +148,27 @@ class Config
),
'db_ssl.key' => array(
'type' => 'string',
+ 'description' => 'Path to client key file for SSL',
'default' => null,
'value' => '',
'source_of_value' => '',
- 'show_in_conf_sample' => true,
+ 'show_in_conf_sample' => false,
),
'db_ssl.cert' => array(
'type' => 'string',
+ 'description' => 'Path to client certificate file for SSL',
'default' => null,
'value' => '',
'source_of_value' => '',
- 'show_in_conf_sample' => true,
+ 'show_in_conf_sample' => false,
),
'db_ssl.ca' => array(
'type' => 'string',
+ 'description' => 'Path to certificate authority file for SSL',
'default' => null,
'value' => '',
'source_of_value' => '',
- 'show_in_conf_sample' => true,
+ 'show_in_conf_sample' => false,
),
'db_ssl.capath' => array(
'type' => 'string',
@@ -173,14 +176,15 @@ class Config
'default' => null,
'value' => '',
'source_of_value' => '',
- 'show_in_conf_sample' => true,
+ 'show_in_conf_sample' => false,
),
'db_ssl.cipher' => array(
'type' => 'string',
+ 'description' => 'Optional : separated list of permissible cyphers to use for SSL encryption',
'default' => null,
'value' => '',
'source_of_value' => '',
- 'show_in_conf_sample' => true,
+ 'show_in_conf_sample' => false,
),
'db_character_set' => array(
'type' => 'string',
@@ -1877,7 +1881,7 @@ class Config
{
$this->Set('db_ssl.key', $aParamValues['db_ssl_key']);
}
- if (isset($aParamValues['db_ssl_key']))
+ if (isset($aParamValues['db_ssl_cert']))
{
$this->Set('db_ssl.cert', $aParamValues['db_ssl_cert']);
}
@@ -1885,6 +1889,10 @@ class Config
{
$this->Set('db_ssl.ca', $aParamValues['db_ssl_ca']);
}
+ if (isset($aParamValues['db_ssl_capath']))
+ {
+ $this->Set('db_ssl.capath', $aParamValues['db_ssl_capath']);
+ }
if (isset($aParamValues['db_ssl_cipher']))
{
$this->Set('db_ssl.cipher', $aParamValues['db_ssl_cipher']);
@@ -1900,6 +1908,11 @@ class Config
$aSelectedModules = null;
}
$this->UpdateIncludes($sModulesDir, $aSelectedModules);
+
+ if (isset($aParamValues['source_dir']))
+ {
+ $this->Set('source_dir', $aParamValues['source_dir']);
+ }
}
/**
diff --git a/core/mutex.class.inc.php b/core/mutex.class.inc.php
index e19a6aa09..aba805b76 100644
--- a/core/mutex.class.inc.php
+++ b/core/mutex.class.inc.php
@@ -43,10 +43,14 @@ class iTopMutex
protected $sDBSSLKey;
protected $sDBSSLCert;
protected $sDBSSLCA;
+ protected $sDBSSLCaPath;
protected $sDBSSLCipher;
static protected $aAcquiredLocks = array(); // Number of instances of the Mutex, having the lock, in this page
- public function __construct($sName, $sDBHost = null, $sDBUser = null, $sDBPwd = null)
+ public function __construct(
+ $sName, $sDBHost = null, $sDBUser = null, $sDBPwd = null, $sDBSSLKey = null, $sDBSSLCert = null,
+ $sDBSSLCA = null, $sDBSSLCaPath = null, $sDBSSLCypher = null
+ )
{
// Compute the name of a lock for mysql
// Note: names are server-wide!!! So let's make the name specific to this iTop instance
@@ -60,10 +64,13 @@ class iTopMutex
$this->sDBPwd = is_null($sDBPwd) ? $oConfig->Get('db_pwd') : $sDBPwd;
$this->sDBName = $oConfig->Get('db_name');
$sDBSubname = $oConfig->Get('db_subname');
- $this->sDBSSLKey = $oConfig->Get('db_ssl.key');
- $this->sDBSSLCert = $oConfig->Get('db_ssl.cert');
- $this->sDBSSLCA = $oConfig->Get('db_ssl.ca');
- $this->sDBSSLCipher = $oConfig->Get('db_ssl.cipher');
+
+ $this->sDBSSLKey = is_null($sDBSSLKey) ? $oConfig->Get('db_ssl.key') : $sDBSSLKey;
+ $this->sDBSSLCert = is_null($sDBSSLCert) ? $oConfig->Get('db_ssl.key') : $sDBSSLCert;
+ $this->sDBSSLCA = is_null($sDBSSLCA) ? $oConfig->Get('db_ssl.key') : $sDBSSLCA;
+ $this->sDBSSLCaPath = is_null($sDBSSLCaPath) ? $oConfig->Get('db_ssl.key') : $sDBSSLCaPath;
+ $this->sDBSSLCipher = is_null($sDBSSLCypher) ? $oConfig->Get('db_ssl.key') : $sDBSSLCypher;
+
$this->sName = 'itop.'.$sName;
$this->sName = $sName;
if (substr($sName, -strlen($this->sDBName.$sDBSubname)) != $this->sDBName.$sDBSubname)
@@ -84,7 +91,7 @@ class iTopMutex
self::$aAcquiredLocks[$this->sName] = 0;
}
- // It is a MUST to create a dedicated session each time a lock is required, because
+ // It is MANDATORY to create a dedicated session each time a lock is required, because
// using GET_LOCK anytime on the same session will RELEASE the current and unique session lock (known issue)
$this->InitMySQLSession();
}
@@ -234,10 +241,11 @@ class iTopMutex
$sSSLKey = $this->sDBSSLKey;
$sSSLCert = $this->sDBSSLCert;
$sSSLCA = $this->sDBSSLCA;
+ $sSSLCaPath = $this->sDBSSLCaPath;
$sSSLCipher = $this->sDBSSLCipher;
$this->hDBLink = CMDBSource::GetMysqliInstance($sServer, $sUser, $sPwd, $sSource, $sSSLKey, $sSSLCert, $sSSLCA,
- $sSSLCipher);
+ $sSSLCaPath, $sSSLCipher);
if (!$this->hDBLink)
{
diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php
index c0131193b..fa523577d 100644
--- a/setup/applicationinstaller.class.inc.php
+++ b/setup/applicationinstaller.class.inc.php
@@ -106,260 +106,238 @@ class ApplicationInstaller
/**
* Executes the next step of the installation and reports about the progress
* and the next step to perform
+ *
* @param string $sStep The identifier of the step to execute
- * @return hash An array of (status => , message => , percentage-completed => , next-step => , next-step-label => )
+ *
+ * @return array (status => , message => , percentage-completed => , next-step => , next-step-label => )
*/
public function ExecuteStep($sStep = '')
{
try
{
- switch($sStep)
+ switch ($sStep)
{
- case '':
- $aResult = array(
- 'status' => self::OK,
- 'message' => '',
- 'percentage-completed' => 0,
- 'next-step' => 'copy',
- 'next-step-label' => 'Copying data model files',
- );
-
- // Log the parameters...
- $oDoc = new DOMDocument('1.0', 'UTF-8');
- $oDoc->preserveWhiteSpace = false;
- $oDoc->formatOutput = true;
- $this->oParams->ToXML($oDoc, null, 'installation');
- $sXML = $oDoc->saveXML();
- $sSafeXml = preg_replace("|([^<]*)|", "**removed**", $sXML);
- SetupPage::log_info("======= Installation starts =======\nParameters:\n$sSafeXml\n");
-
- // Save the response file as a stand-alone file as well
- $sFileName = 'install-'.date('Y-m-d');
- $index = 0;
- while(file_exists(APPROOT.'log/'.$sFileName.'.xml'))
- {
- $index++;
- $sFileName = 'install-'.date('Y-m-d').'-'.$index;
- }
- file_put_contents(APPROOT.'log/'.$sFileName.'.xml', $sSafeXml);
-
- break;
-
- case 'copy':
- $aPreinstall = $this->oParams->Get('preinstall');
- $aCopies = $aPreinstall['copies'];
+ case '':
+ $aResult = array(
+ 'status' => self::OK,
+ 'message' => '',
+ 'percentage-completed' => 0,
+ 'next-step' => 'copy',
+ 'next-step-label' => 'Copying data model files',
+ );
- $sReport = self::DoCopy($aCopies);
- $sReport = "Copying...";
+ // Log the parameters...
+ $oDoc = new DOMDocument('1.0', 'UTF-8');
+ $oDoc->preserveWhiteSpace = false;
+ $oDoc->formatOutput = true;
+ $this->oParams->ToXML($oDoc, null, 'installation');
+ $sXML = $oDoc->saveXML();
+ $sSafeXml = preg_replace("|([^<]*)|", "**removed**", $sXML);
+ SetupPage::log_info("======= Installation starts =======\nParameters:\n$sSafeXml\n");
- $aResult = array(
- 'status' => self::OK,
- 'message' => $sReport,
- );
- if (isset($aPreinstall['backup']))
- {
- $aResult['next-step'] = 'backup';
- $aResult['next-step-label'] = 'Performing a backup of the database';
- $aResult['percentage-completed'] = 20;
- }
- else
- {
- $aResult['next-step'] = 'compile';
- $aResult['next-step-label'] = 'Compiling the data model';
- $aResult['percentage-completed'] = 20;
- }
- break;
-
- case 'backup':
- $aPreinstall = $this->oParams->Get('preinstall');
- // __DB__-%Y-%m-%d
- $sDestination = $aPreinstall['backup']['destination'];
- $sSourceConfigFile = $aPreinstall['backup']['configuration_file'];
- $aDBParams = $this->oParams->Get('database');
-
- self::DoBackup($aDBParams['server'], $aDBParams['user'], $aDBParams['pwd'], $aDBParams['name'], $aDBParams['prefix'], $sDestination, $sSourceConfigFile);
-
- $aResult = array(
- 'status' => self::OK,
- 'message' => "Created backup",
- 'next-step' => 'compile',
- 'next-step-label' => 'Compiling the data model',
- 'percentage-completed' => 20,
- );
- break;
-
- case 'compile':
- $aSelectedModules = $this->oParams->Get('selected_modules');
- $sSourceDir = $this->oParams->Get('source_dir', 'datamodels/latest');
- $sExtensionDir = $this->oParams->Get('extensions_dir', 'extensions');
- $sTargetEnvironment = $this->oParams->Get('target_env', '');
- if ($sTargetEnvironment == '')
- {
- $sTargetEnvironment = 'production';
- }
- $sTargetDir = 'env-'.$sTargetEnvironment;
- $bUseSymbolicLinks = false;
- $aMiscOptions = $this->oParams->Get('options', array());
- if (isset($aMiscOptions['symlinks']) && $aMiscOptions['symlinks'] )
- {
- if (function_exists('symlink'))
+ // Save the response file as a stand-alone file as well
+ $sFileName = 'install-'.date('Y-m-d');
+ $index = 0;
+ while (file_exists(APPROOT.'log/'.$sFileName.'.xml'))
{
- $bUseSymbolicLinks = true;
- SetupPage::log_info("Using symbolic links instead of copying data model files (for developers only!)");
+ $index++;
+ $sFileName = 'install-'.date('Y-m-d').'-'.$index;
+ }
+ file_put_contents(APPROOT.'log/'.$sFileName.'.xml', $sSafeXml);
+
+ break;
+
+ case 'copy':
+ $aPreinstall = $this->oParams->Get('preinstall');
+ $aCopies = $aPreinstall['copies'];
+
+ self::DoCopy($aCopies);
+ $sReport = "Copying...";
+
+ $aResult = array(
+ 'status' => self::OK,
+ 'message' => $sReport,
+ );
+ if (isset($aPreinstall['backup']))
+ {
+ $aResult['next-step'] = 'backup';
+ $aResult['next-step-label'] = 'Performing a backup of the database';
+ $aResult['percentage-completed'] = 20;
}
else
{
- SetupPage::log_info("Symbolic links (function symlinks) does not seem to be supported on this platform (OS/PHP version).");
+ $aResult['next-step'] = 'compile';
+ $aResult['next-step-label'] = 'Compiling the data model';
+ $aResult['percentage-completed'] = 20;
}
- }
-
- self::DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sTargetEnvironment, $bUseSymbolicLinks);
-
- $aResult = array(
- 'status' => self::OK,
- 'message' => '',
- 'next-step' => 'db-schema',
- 'next-step-label' => 'Updating database schema',
- 'percentage-completed' => 40,
- );
- break;
-
+ break;
+
+ case 'backup':
+ $aPreinstall = $this->oParams->Get('preinstall');
+ // __DB__-%Y-%m-%d
+ $sDestination = $aPreinstall['backup']['destination'];
+ $sSourceConfigFile = $aPreinstall['backup']['configuration_file'];
+ $aDBParams = $this->oParams->Get('database');
+
+ self::DoBackup($aDBParams['server'], $aDBParams['user'], $aDBParams['pwd'], $aDBParams['name'],
+ $aDBParams['prefix'], $sDestination, $sSourceConfigFile);
+
+ $aResult = array(
+ 'status' => self::OK,
+ 'message' => "Created backup",
+ 'next-step' => 'compile',
+ 'next-step-label' => 'Compiling the data model',
+ 'percentage-completed' => 20,
+ );
+ break;
+
+ case 'compile':
+ $aSelectedModules = $this->oParams->Get('selected_modules');
+ $sSourceDir = $this->oParams->Get('source_dir', 'datamodels/latest');
+ $sExtensionDir = $this->oParams->Get('extensions_dir', 'extensions');
+ $sTargetEnvironment = $this->oParams->Get('target_env', '');
+ if ($sTargetEnvironment == '')
+ {
+ $sTargetEnvironment = 'production';
+ }
+ $sTargetDir = 'env-'.$sTargetEnvironment;
+ $bUseSymbolicLinks = false;
+ $aMiscOptions = $this->oParams->Get('options', array());
+ if (isset($aMiscOptions['symlinks']) && $aMiscOptions['symlinks'])
+ {
+ if (function_exists('symlink'))
+ {
+ $bUseSymbolicLinks = true;
+ SetupPage::log_info("Using symbolic links instead of copying data model files (for developers only!)");
+ }
+ else
+ {
+ SetupPage::log_info("Symbolic links (function symlinks) does not seem to be supported on this platform (OS/PHP version).");
+ }
+ }
+
+ self::DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sTargetEnvironment,
+ $bUseSymbolicLinks);
+
+ $aResult = array(
+ 'status' => self::OK,
+ 'message' => '',
+ 'next-step' => 'db-schema',
+ 'next-step-label' => 'Updating database schema',
+ 'percentage-completed' => 40,
+ );
+ break;
+
case 'db-schema':
- $sMode = $this->oParams->Get('mode');
- $aSelectedModules = $this->oParams->Get('selected_modules', array());
- $sTargetEnvironment = $this->oParams->Get('target_env', '');
- if ($sTargetEnvironment == '')
- {
- $sTargetEnvironment = 'production';
- }
- $sTargetDir = 'env-'.$sTargetEnvironment;
- $aDBParams = $this->oParams->Get('database');
- $sDBServer = $aDBParams['server'];
- $sDBUser = $aDBParams['user'];
- $sDBPwd = $aDBParams['pwd'];
- $sDBName = $aDBParams['name'];
- $sDBPrefix = $aDBParams['prefix'];
- $bOldAddon = $this->oParams->Get('old_addon', false);
- $sUrl = $this->oParams->Get('url', '');
-
- self::DoUpdateDBSchema($sMode, $aSelectedModules, $sTargetDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sTargetEnvironment, $bOldAddon, $sUrl);
-
- $aResult = array(
- 'status' => self::OK,
- 'message' => '',
- 'next-step' => 'after-db-create',
- 'next-step-label' => 'Creating profiles',
- 'percentage-completed' => 60,
- );
- break;
-
+ $aSelectedModules = $this->oParams->Get('selected_modules', array());
+ $sTargetEnvironment = $this->oParams->Get('target_env', '');
+ if ($sTargetEnvironment == '')
+ {
+ $sTargetEnvironment = 'production';
+ }
+ $sTargetDir = 'env-'.$sTargetEnvironment;
+ $aParamValues = $this->GetParamValues($this->oParams);
+ $bOldAddon = $this->oParams->Get('old_addon', false);
+ $sUrl = $this->oParams->Get('url', '');
+
+ self::DoUpdateDBSchema($aSelectedModules, $sTargetDir, $aParamValues, $sTargetEnvironment,
+ $bOldAddon, $sUrl);
+
+ $aResult = array(
+ 'status' => self::OK,
+ 'message' => '',
+ 'next-step' => 'after-db-create',
+ 'next-step-label' => 'Creating profiles',
+ 'percentage-completed' => 60,
+ );
+ break;
+
case 'after-db-create':
- $sMode = $this->oParams->Get('mode');
- $sTargetEnvironment = $this->oParams->Get('target_env', '');
- if ($sTargetEnvironment == '')
- {
- $sTargetEnvironment = 'production';
- }
- $sTargetDir = 'env-'.$sTargetEnvironment;
- $aDBParams = $this->oParams->Get('database');
- $sDBServer = $aDBParams['server'];
- $sDBUser = $aDBParams['user'];
- $sDBPwd = $aDBParams['pwd'];
- $sDBName = $aDBParams['name'];
- $sDBPrefix = $aDBParams['prefix'];
- $aAdminParams = $this->oParams->Get('admin_account');
- $sAdminUser = $aAdminParams['user'];
- $sAdminPwd = $aAdminParams['pwd'];
- $sAdminLanguage = $aAdminParams['language'];
- $sLanguage = $this->oParams->Get('language');
- $aSelectedModules = $this->oParams->Get('selected_modules', array());
- $sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0');
- $bOldAddon = $this->oParams->Get('old_addon', false);
- $sSourceDir = $this->oParams->Get('source_dir', '');
-
- self::AfterDBCreate($sMode, $sTargetDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sAdminUser,
- $sAdminPwd, $sAdminLanguage, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sDataModelVersion, $sSourceDir);
-
- $aResult = array(
- 'status' => self::OK,
- 'message' => '',
- 'next-step' => 'load-data',
- 'next-step-label' => 'Loading data',
- 'percentage-completed' => 80,
- );
- break;
-
+ $sTargetEnvironment = $this->oParams->Get('target_env', '');
+ if ($sTargetEnvironment == '')
+ {
+ $sTargetEnvironment = 'production';
+ }
+ $sTargetDir = 'env-'.$sTargetEnvironment;
+ $aParamValues = $this->GetParamValues($this->oParams);
+ $aAdminParams = $this->oParams->Get('admin_account');
+ $sAdminUser = $aAdminParams['user'];
+ $sAdminPwd = $aAdminParams['pwd'];
+ $sAdminLanguage = $aAdminParams['language'];
+ $aSelectedModules = $this->oParams->Get('selected_modules', array());
+ $bOldAddon = $this->oParams->Get('old_addon', false);
+
+ self::AfterDBCreate($sTargetDir, $aParamValues, $sAdminUser, $sAdminPwd, $sAdminLanguage,
+ $aSelectedModules, $sTargetEnvironment, $bOldAddon);
+
+ $aResult = array(
+ 'status' => self::OK,
+ 'message' => '',
+ 'next-step' => 'load-data',
+ 'next-step-label' => 'Loading data',
+ 'percentage-completed' => 80,
+ );
+ break;
+
case 'load-data':
- $aSelectedModules = $this->oParams->Get('selected_modules');
- $sTargetEnvironment = $this->oParams->Get('target_env', '');
- $sTargetDir = 'env-'.(($sTargetEnvironment == '') ? 'production' : $sTargetEnvironment);
- $aDBParams = $this->oParams->Get('database');
- $sDBServer = $aDBParams['server'];
- $sDBUser = $aDBParams['user'];
- $sDBPwd = $aDBParams['pwd'];
- $sDBName = $aDBParams['name'];
- $sDBPrefix = $aDBParams['prefix'];
- $bOldAddon = $this->oParams->Get('old_addon', false);
- $bSampleData = ($this->oParams->Get('sample_data', 0) == 1);
-
- self::DoLoadFiles($aSelectedModules, $sTargetDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sTargetEnvironment, $bOldAddon, $bSampleData);
-
- $aResult = array(
- 'status' => self::INFO,
- 'message' => 'All data loaded',
- 'next-step' => 'create-config',
- 'next-step-label' => 'Creating the configuration File',
- 'percentage-completed' => 99,
- );
- break;
-
+ $aSelectedModules = $this->oParams->Get('selected_modules');
+ $sTargetEnvironment = $this->oParams->Get('target_env', '');
+ $sTargetDir = 'env-'.(($sTargetEnvironment == '') ? 'production' : $sTargetEnvironment);
+ $aParamValues = $this->GetParamValues($this->oParams);
+ $bOldAddon = $this->oParams->Get('old_addon', false);
+ $bSampleData = ($this->oParams->Get('sample_data', 0) == 1);
+
+ self::DoLoadFiles($aSelectedModules, $sTargetDir, $aParamValues, $sTargetEnvironment, $bOldAddon,
+ $bSampleData);
+
+ $aResult = array(
+ 'status' => self::INFO,
+ 'message' => 'All data loaded',
+ 'next-step' => 'create-config',
+ 'next-step-label' => 'Creating the configuration File',
+ 'percentage-completed' => 99,
+ );
+ break;
+
case 'create-config':
- $sMode = $this->oParams->Get('mode');
- $sTargetEnvironment = $this->oParams->Get('target_env', '');
- if ($sTargetEnvironment == '')
- {
- $sTargetEnvironment = 'production';
- }
- $sTargetDir = 'env-'.$sTargetEnvironment;
- $aDBParams = $this->oParams->Get('database');
- $sDBServer = $aDBParams['server'];
- $sDBUser = $aDBParams['user'];
- $sDBPwd = $aDBParams['pwd'];
- $sDBName = $aDBParams['name'];
- $sDBPrefix = $aDBParams['prefix'];
- $sUrl = $this->oParams->Get('url', '');
- $sGraphvizPath = $this->oParams->Get('graphviz_path', '');
- $sLanguage = $this->oParams->Get('language', '');
- $aSelectedModuleCodes = $this->oParams->Get('selected_modules', array());
- $aSelectedExtensionCodes = $this->oParams->Get('selected_extensions', array());
- $bOldAddon = $this->oParams->Get('old_addon', false);
- $sSourceDir = $this->oParams->Get('source_dir', '');
- $sPreviousConfigFile = $this->oParams->Get('previous_configuration_file', '');
- $sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0');
-
- self::DoCreateConfig($sMode, $sTargetDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModuleCodes, $aSelectedExtensionCodes, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion, $sGraphvizPath);
-
- $aResult = array(
- 'status' => self::INFO,
- 'message' => 'Configuration file created',
- 'next-step' => '',
- 'next-step-label' => 'Completed',
- 'percentage-completed' => 100,
- );
- break;
-
-
+ $sTargetEnvironment = $this->oParams->Get('target_env', '');
+ if ($sTargetEnvironment == '')
+ {
+ $sTargetEnvironment = 'production';
+ }
+
+ $sTargetDir = 'env-'.$sTargetEnvironment;
+ $sPreviousConfigFile = $this->oParams->Get('previous_configuration_file', '');
+ $sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0');
+ $bOldAddon = $this->oParams->Get('old_addon', false);
+ $aSelectedModuleCodes = $this->oParams->Get('selected_modules', array());
+ $aSelectedExtensionCodes = $this->oParams->Get('selected_extensions', array());
+ $aParamValues = $this->GetParamValues($this->oParams);
+
+ self::DoCreateConfig($sTargetDir, $sPreviousConfigFile, $sTargetEnvironment, $sDataModelVersion,
+ $bOldAddon, $aSelectedModuleCodes, $aSelectedExtensionCodes, $aParamValues);
+
+ $aResult = array(
+ 'status' => self::INFO,
+ 'message' => 'Configuration file created',
+ 'next-step' => '',
+ 'next-step-label' => 'Completed',
+ 'percentage-completed' => 100,
+ );
+ break;
+
+
default:
- $aResult = array(
- 'status' => self::ERROR,
- 'message' => '',
- 'next-step' => '',
- 'next-step-label' => "Unknown setup step '$sStep'.",
- 'percentage-completed' => 100,
- );
+ $aResult = array(
+ 'status' => self::ERROR,
+ 'message' => '',
+ 'next-step' => '',
+ 'next-step-label' => "Unknown setup step '$sStep'.",
+ 'percentage-completed' => 100,
+ );
}
}
- catch(Exception $e)
+ catch (Exception $e)
{
$aResult = array(
'status' => self::ERROR,
@@ -368,12 +346,12 @@ class ApplicationInstaller
'next-step-label' => '',
'percentage-completed' => 100,
);
-
+
SetupPage::log_error('An exception occurred: '.$e->getMessage().' at line '.$e->getLine().' in file '.$e->getFile());
$idx = 0;
// Log the call stack, but not the parameters since they may contain passwords or other sensitive data
SetupPage::log("Call stack:");
- foreach($e->getTrace() as $aTrace)
+ foreach ($e->getTrace() as $aTrace)
{
$sLine = empty($aTrace['line']) ? "" : $aTrace['line'];
$sFile = empty($aTrace['file']) ? "" : $aTrace['file'];
@@ -385,9 +363,40 @@ class ApplicationInstaller
$idx++;
}
}
+
return $aResult;
}
+ /**
+ * @param $oParams
+ *
+ * @return array to use with {@see Config::UpdateFromParams}
+ */
+ private function GetParamValues($oParams)
+ {
+ $aDBParams = $this->oParams->Get('database');
+ $aParamValues = array(
+ 'mode' => $oParams->Get('mode'),
+ 'db_server' => $aDBParams['server'],
+ 'db_user' => $aDBParams['user'],
+ 'db_pwd' => $aDBParams['pwd'],
+ 'db_name' => $aDBParams['name'],
+ 'new_db_name' => $aDBParams['name'],
+ 'db_prefix' => $aDBParams['prefix'],
+ 'db_ssl_key' => $aDBParams['db_ssl_key'],
+ 'db_ssl_cert' => $aDBParams['db_ssl_cert'],
+ 'db_ssl_ca' => $aDBParams['db_ssl_ca'],
+ 'db_ssl_capath' => $aDBParams['db_ssl_capath'],
+ 'db_ssl_cipher' => $aDBParams['db_ssl_cipher'],
+ 'application_path' => $oParams->Get('url', ''),
+ 'language' => $oParams->Get('language', ''),
+ 'graphviz_path' => $oParams->Get('graphviz_path', ''),
+ 'source_dir' => $oParams->Get('source_dir', ''),
+ );
+
+ return $aParamValues;
+ }
+
protected static function DoCopy($aCopies)
{
$aReports = array();
@@ -555,23 +564,19 @@ class ApplicationInstaller
file_put_contents($sInstanceUUIDFile, $sIntanceUUID);
}
}
-
- protected static function DoUpdateDBSchema($sMode, $aSelectedModules, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sTargetEnvironment = '', $bOldAddon = false, $sAppRootUrl = '')
+
+ protected static function DoUpdateDBSchema(
+ $aSelectedModules, $sModulesDir, $aParamValues, $sTargetEnvironment = '', $bOldAddon = false, $sAppRootUrl = ''
+ )
{
SetupPage::log_info("Update Database Schema for environment '$sTargetEnvironment'.");
+ $sMode = $aParamValues['mode'];
+ $sDBPrefix = $aParamValues['db_prefix'];
+ $sDBName = $aParamValues['db_name'];
$oConfig = new Config();
-
- $aParamValues = array(
- 'mode' => $sMode,
- 'db_server' => $sDBServer,
- 'db_user' => $sDBUser,
- 'db_pwd' => $sDBPwd,
- 'db_name' => $sDBName,
- 'db_prefix' => $sDBPrefix,
- 'application_path' => $sAppRootUrl,
- );
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
+
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
@@ -737,23 +742,18 @@ class ApplicationInstaller
SetupPage::log_info("Database Schema Successfully Updated for environment '$sTargetEnvironment'.");
}
-
- protected static function AfterDBCreate($sMode, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sAdminUser, $sAdminPwd, $sAdminLanguage, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sDataModelVersion, $sSourceDir)
- {
+ protected static function AfterDBCreate(
+ $sModulesDir, $aParamValues, $sAdminUser, $sAdminPwd, $sAdminLanguage, $aSelectedModules, $sTargetEnvironment,
+ $bOldAddon
+ )
+ {
SetupPage::log_info('After Database Creation');
+ $sMode = $aParamValues['mode'];
$oConfig = new Config();
-
- $aParamValues = array(
- 'mode' => $sMode,
- 'db_server' => $sDBServer,
- 'db_user' => $sDBUser,
- 'db_pwd' => $sDBPwd,
- 'db_name' => $sDBName,
- 'db_prefix' => $sDBPrefix,
- );
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
+
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
@@ -761,8 +761,7 @@ class ApplicationInstaller
'user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php',
));
}
- $oConfig->Set('source_dir', $sSourceDir); // Needed by RecordInstallation below
-
+
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
$oProductionEnv->InitDataModel($oConfig, true); // load data model and connect to the database
self::$bMetaModelStarted = true; // No need to reload the final MetaModel in case the installer runs synchronously
@@ -808,20 +807,15 @@ class ApplicationInstaller
return false;
}
}
-
- protected static function DoLoadFiles($aSelectedModules, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sTargetEnvironment = 'production', $bOldAddon = false, $bSampleData = false)
- {
- $aParamValues = array(
- 'db_server' => $sDBServer,
- 'db_user' => $sDBUser,
- 'db_pwd' => $sDBPwd,
- 'db_name' => $sDBName,
- 'new_db_name' => $sDBName,
- 'db_prefix' => $sDBPrefix,
- );
- $oConfig = new Config();
+ protected static function DoLoadFiles(
+ $aSelectedModules, $sModulesDir, $aParamValues, $sTargetEnvironment = 'production', $bOldAddon = false,
+ $bSampleData = false
+ )
+ {
+ $oConfig = new Config();
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
+
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
@@ -846,23 +840,28 @@ class ApplicationInstaller
//
$oProductionEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDataLoad');
}
-
- protected static function DoCreateConfig($sMode, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModuleCodes, $aSelectedExtensionCodes, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion, $sGraphvizPath)
- {
- $aParamValues = array(
- 'mode' => $sMode,
- 'db_server' => $sDBServer,
- 'db_user' => $sDBUser,
- 'db_pwd' => $sDBPwd,
- 'db_name' => $sDBName,
- 'new_db_name' => $sDBName,
- 'db_prefix' => $sDBPrefix,
- 'application_path' => $sUrl,
- 'language' => $sLanguage,
- 'graphviz_path' => $sGraphvizPath,
- 'selected_modules' => implode(',', $aSelectedModuleCodes)
- );
-
+
+ /**
+ * @param string $sModulesDir
+ * @param string $sPreviousConfigFile
+ * @param string $sTargetEnvironment
+ * @param string $sDataModelVersion
+ * @param boolean $bOldAddon
+ * @param array $aSelectedModuleCodes
+ * @param array $aSelectedExtensionCodes
+ * @param array $aParamValues parameters array used to create config file using {@see Config::UpdateFromParams}
+ *
+ * @throws \ConfigException
+ * @throws \CoreException
+ * @throws \Exception
+ */
+ protected static function DoCreateConfig(
+ $sModulesDir, $sPreviousConfigFile, $sTargetEnvironment, $sDataModelVersion, $bOldAddon, $aSelectedModuleCodes,
+ $aSelectedExtensionCodes, $aParamValues
+ ) {
+ $aParamValues['selected_modules'] = implode(',', $aSelectedModuleCodes);
+ $sMode = $aParamValues['mode'];
+
$bPreserveModuleSettings = false;
if ($sMode == 'upgrade')
{
@@ -895,7 +894,6 @@ class ApplicationInstaller
'user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php',
));
}
- $oConfig->Set('source_dir', $sSourceDir);
// Record which modules are installed...
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
diff --git a/setup/extensionsmap.class.inc.php b/setup/extensionsmap.class.inc.php
index 729e11aa5..0976862ad 100644
--- a/setup/extensionsmap.class.inc.php
+++ b/setup/extensionsmap.class.inc.php
@@ -542,9 +542,9 @@ class iTopExtensionsMap
*/
public function LoadChoicesFromDatabase(Config $oConfig)
{
- $aInstalledExtensions = array();
try
{
+ $aInstalledExtensions = array();
if (CMDBSource::DBName() === null)
{
CMDBSource::InitFromConfig($oConfig);
@@ -555,7 +555,6 @@ class iTopExtensionsMap
catch (MySQLException $e)
{
// No database or erroneous information
- $aInstalledExtensions = array();
return false;
}
diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php
index cdfd32009..d9cfeeaab 100644
--- a/setup/setuputils.class.inc.php
+++ b/setup/setuputils.class.inc.php
@@ -817,6 +817,10 @@ class SetupUtils
if ($aResult['found'])
{
$oPrevConf = new Config($sConfigFile);
+
+ $sDbSslKey = $oPrevConf->Get('db_ssl.key');
+ $sDbSslCert = $oPrevConf->Get('db_ssl.cert');
+ $sDbSslCa = $oPrevConf->Get('db_ssl.ca');
$aResult = array(
'found' => true,
'source_dir' => $sSourceDir,
@@ -827,8 +831,16 @@ class SetupUtils
'db_pwd' => $oPrevConf->Get('db_pwd'),
'db_name' => $oPrevConf->Get('db_name'),
'db_prefix' => $oPrevConf->Get('db_subname'),
+ 'db_ssl_key' => $sDbSslKey,
+ 'db_ssl_cert' => $sDbSslCert,
+ 'db_ssl_ca' => $sDbSslCa,
+ 'db_ssl_capath' => $oPrevConf->Get('db_ssl.capath'),
+ 'db_ssl_cipher' => $oPrevConf->Get('db_ssl.cipher'),
'graphviz_path' => $oPrevConf->Get('graphviz_path'),
);
+
+ // SSL options checkbox
+ $aResult['db_ssl'] = (CMDBSource::IsDbConnectionUsingSsl($sDbSslKey, $sDbSslCert, $sDbSslCa));
}
return $aResult;
@@ -858,15 +870,63 @@ class SetupUtils
return sprintf('%.2f %s', $fBytes, $aSizes[$index]);
}
-
- static function DisplayDBParameters($oPage, $bAllowDBCreation, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sNewDBName = '')
- {
+
+ /**
+ * @param \WebPage $oPage
+ * @param boolean $bAllowDBCreation
+ * @param string $sDBServer
+ * @param string $sDBUser
+ * @param string $sDBPwd
+ * @param string $sDBName
+ * @param string $sDBPrefix
+ * @param string $sSSLKey
+ * @param string $sSSLCert
+ * @param string $sSSLCA
+ * @param string $sSSLCaPath
+ * @param string $sSSLCypher
+ * @param string $sNewDBName
+ */
+ static function DisplayDBParameters(
+ $oPage, $bAllowDBCreation, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sSSLKey, $sSSLCert, $sSSLCA,
+ $sSSLCaPath, $sSSLCypher, $sNewDBName = ''
+ ) {
$oPage->add('
| ');
$oPage->add(' |