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('
Database Server Connection'); - $oPage->add(''); + $oPage->add('
'); + + //-- DB connection params + $oPage->add(''); $oPage->add(''); $oPage->add(''); $oPage->add(''); + $oPage->add(''); + + //-- SSL params (N°1260) + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add('
Server Name:E.g. "localhost", "dbserver.mycompany.com" or "192.142.10.23"
Login:The account must have the following privileges on the database: SELECT, INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, CREATE VIEW, SHOW VIEW, LOCK TABLE, SUPER, TRIGGER
Password:
Warning: please make sure of all the system requirements, and test the connection using the simple test page available on Combodo\'s Wiki
SSL Key:Path to client key file for SSL
SSL CERT:Path to client certificate file for SSL
SSL CA:Path to certificate authority file for SSL
SSL CA path:
SSL cypher:Optional : separated list of permissible cyphers to use for SSL encryption
'); $oPage->add('
'); $oPage->add(''); @@ -893,6 +953,37 @@ class SetupUtils $oPage->add(''); $oPage->add(' '); $oPage->add(''); + + // SSL checkbox toggle + $oPage->add_script(<<<'EOF' +function toggleSslOptions() { + $("tbody#ssl_options>tr").not("tr:first-child").toggle(); + updateSslImage(); +} +function updateSslImage() { + $dbSslImg = $("img#db_ssl_img"); + imgPath = "../images/"; + dbImgUrl = ($("tbody#ssl_options>tr:nth-child(2)>td:visible").length > 0) + ? "minus.gif" + : "plus.gif"; + $dbSslImg.attr("src", imgPath+dbImgUrl); +} +EOF + ); + $bSslEnabled = CMDBSource::IsDbConnectionUsingSsl($sSSLKey, $sSSLCert, $sSSLCA); + if (!$bSslEnabled) + { + $oPage->add_ready_script('toggleSslOptions();'); + } + $oPage->add_ready_script( + <<tr>th>label").click(function() { + toggleSslOptions(); +}); +updateSslImage(); +EOF + ); + $oPage->add_script( <<td>input", function() { CheckDBConnection(); }); + +$("#db_new_name").on("click keyup change", function() { $("#create_db").attr("checked", "checked"); WizardUpdateButtons(); }); +$("#db_name").on("click keyup change", function() { $("#existing_db").attr("checked", "checked"); WizardUpdateButtons(); }); +$("#db_prefix").on("keyup change", function() { WizardUpdateButtons(); }); +$("#existing_db").on("click change", function() { WizardUpdateButtons(); }); +$("#create_db").on("click change", function() { WizardUpdateButtons(); }); EOF ); } - /** - * Helper function : check the connection to the database, verify a few conditions (minimum version, etc...) and (if connected) - * enumerate the existing databases (if possible) - * - * @param string $sDBServer - * @param string $sDBUser - * @param string $sDBPwd - * - * @return mixed false if the connection failed or array('checks' => Array of CheckResult, 'databases' => Array of database names (as strings) or null if not allowed) - */ - static function CheckDbServer($sDBServer, $sDBUser, $sDBPwd, $sSSLKey = NULL, $sSSLCert = NULL, $sSSLCA = NULL, $sSSLCipher = NULL) + /** + * Helper function : check the connection to the database, verify a few conditions (minimum version, etc...) and + * (if connected) enumerate the existing databases (if possible) + * + * @param string $sDBServer + * @param string $sDBUser + * @param string $sDBPwd + * @param string $sSSLKey + * @param string $sSSLCert + * @param string $sSSLCA + * @param string $sSSLCaPath + * @param string $sSSLCipher + * + * @return bool|array false if the connection failed or array('checks' => Array of CheckResult, 'databases' => + * Array of database names (as strings) or null if not allowed) + */ + static function CheckDbServer( + $sDBServer, $sDBUser, $sDBPwd, $sSSLKey = null, $sSSLCert = null, $sSSLCA = null, $sSSLCaPath = null, + $sSSLCipher = null + ) { $aResult = array('checks' => array(), 'databases' => null); + + if (CMDBSource::IsDbConnectionUsingSsl($sSSLKey, $sSSLCert, $sSSLCA)) + { + if (!self::CheckFileExists($sSSLKey, $aResult, 'Can\'t open SSL Key file')) + { + return $aResult; + } + if (!self::CheckFileExists($sSSLCert, $aResult, 'Can\'t open SSL Cert file')) + { + return $aResult; + } + if (!self::CheckFileExists($sSSLCA, $aResult, 'Can\'t open SSL CA file')) + { + return $aResult; + } + } + try { $oDBSource = new CMDBSource; @@ -1076,9 +1197,32 @@ EOF { return false; } + return $aResult; } + /** + * Use to test MySQL SSL files (key, cert, ca) + * + * @param string $sPath + * @param array $aResult passed by reference, will by updated in case of error + * @param $sErrorMessage + * + * @return bool false if file doesn't exist + * @used-by CheckDbServer + */ + private static function CheckFileExists($sPath, &$aResult, $sErrorMessage) + { + if (!is_readable($sPath)) + { + $aResult['checks'][] = new CheckResult(CheckResult::ERROR, $sErrorMessage); + + return false; + } + + return true; + } + /** * @param array $aResult two keys : 'checks' with CheckResult array, 'databases' with list of databases available * @param CMDBSource $oDBSource @@ -1130,11 +1274,13 @@ EOF $sSSLKey = (isset($aParameters['db_ssl_key'])) ? $aParameters['db_ssl_key'] : null; $sSSLCert = isset($aParameters['db_ssl_cert']) ? $aParameters['db_ssl_cert'] : null; $sSSLCA = (isset($aParameters['db_ssl_ca'])) ? $aParameters['db_ssl_ca'] : null; + $sSSLCaPath = (isset($aParameters['db_ssl_capath'])) ? $aParameters['db_ssl_capath'] : null; $sSSLCipher = (isset($aParameters['db_ssl_cipher'])) ? $aParameters['db_ssl_cipher'] : null; $oPage->add_ready_script('oXHRCheckDB = null;'); - $checks = SetupUtils::CheckDbServer($sDBServer, $sDBUser, $sDBPwd, $sSSLKey, $sSSLCert, $sSSLCA, $sSSLCipher); + $checks = SetupUtils::CheckDbServer($sDBServer, $sDBUser, $sDBPwd, $sSSLKey, $sSSLCert, $sSSLCA, $sSSLCaPath, + $sSSLCipher); if ($checks === false) { @@ -1277,6 +1423,11 @@ EOF 'db_pwd' => $oWizard->GetParameter('db_pwd', ''), 'db_name' => $oWizard->GetParameter('db_name', ''), 'db_prefix' => $oWizard->GetParameter('db_prefix', ''), + 'db_ssl_key' => $oWizard->GetParameter('db_ssl_key', ''), + 'db_ssl_cert' => $oWizard->GetParameter('db_ssl_cert', ''), + 'db_ssl_ca' => $oWizard->GetParameter('db_ssl_ca', ''), + 'db_ssl_capath' => $oWizard->GetParameter('db_ssl_capath', ''), + 'db_ssl_cipher' => $oWizard->GetParameter('db_ssl_cipher', ''), 'source_dir' => $sRelativeSourceDir, ); $oConfig->UpdateFromParams($aParamValues, null); @@ -1311,6 +1462,11 @@ EOF return $aAvailableModules; } + /** + * @param WizardController $oWizard + * + * @return array|bool + */ public static function GetApplicationVersion($oWizard) { require_once(APPROOT.'/setup/moduleinstaller.class.inc.php'); @@ -1322,6 +1478,11 @@ EOF 'db_pwd' => $oWizard->GetParameter('db_pwd', ''), 'db_name' => $oWizard->GetParameter('db_name', ''), 'db_prefix' => $oWizard->GetParameter('db_prefix', ''), + 'db_ssl_key' => $oWizard->GetParameter('db_ssl_key', ''), + 'db_ssl_cert' => $oWizard->GetParameter('db_ssl_cert', ''), + 'db_ssl_ca' => $oWizard->GetParameter('db_ssl_ca', ''), + 'db_ssl_capath' => $oWizard->GetParameter('db_ssl_capath', ''), + 'db_ssl_cipher' => $oWizard->GetParameter('db_ssl_cipher', ''), 'source_dir' => '', ); $oConfig->UpdateFromParams($aParamValues, null); diff --git a/setup/wizardcontroller.class.inc.php b/setup/wizardcontroller.class.inc.php index a5c6c04dd..8b9636cef 100644 --- a/setup/wizardcontroller.class.inc.php +++ b/setup/wizardcontroller.class.inc.php @@ -119,6 +119,7 @@ class WizardController { $sCurrentStepClass = utils::ReadParam('_class', $this->sInitialStepClass); $sCurrentState = utils::ReadParam('_state', $this->sInitialState); + /** @var \WizardStep $oStep */ $oStep = new $sCurrentStepClass($this, $sCurrentState); if ($oStep->ValidateParams($sCurrentState)) { diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index 246c9591f..050a10a31 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -177,7 +177,12 @@ class WizStepInstallOrUpgrade extends WizardStep $this->oWizard->SaveParameter('db_prefix', ''); $this->oWizard->SaveParameter('db_backup', false); $this->oWizard->SaveParameter('db_backup_path', ''); - + $this->oWizard->SaveParameter('db_ssl_key', ''); + $this->oWizard->SaveParameter('db_ssl_cert', ''); + $this->oWizard->SaveParameter('db_ssl_ca', ''); + $this->oWizard->SaveParameter('db_ssl_capath', ''); + $this->oWizard->SaveParameter('db_ssl_cipher', ''); + if ($sInstallMode == 'install') { $this->oWizard->SetParameter('install_mode', 'install'); @@ -205,6 +210,11 @@ class WizStepInstallOrUpgrade extends WizardStep $sDBPrefix = $this->oWizard->GetParameter('db_prefix', ''); $bDBBackup = $this->oWizard->GetParameter('db_backup', false); $sDBBackupPath = $this->oWizard->GetParameter('db_backup_path', ''); + $sSSLKey = $this->oWizard->GetParameter('db_ssl_key'); + $sSSLCert = $this->oWizard->GetParameter('db_ssl_cert'); + $sSSLCA = $this->oWizard->GetParameter('db_ssl_ca'); + $sSSLCaPath = $this->oWizard->GetParameter('db_ssl_capath', ''); + $sSSLCypher = $this->oWizard->GetParameter('db_ssl_cipher', ''); $sPreviousVersionDir = ''; if ($sInstallMode == '') { @@ -220,6 +230,11 @@ class WizStepInstallOrUpgrade extends WizardStep $sDBPwd = $aPreviousInstance['db_pwd']; $sDBName = $aPreviousInstance['db_name']; $sDBPrefix = $aPreviousInstance['db_prefix']; + $sSSLKey = $aPreviousInstance['db_ssl_key']; + $sSSLCert = $aPreviousInstance['db_ssl_cert']; + $sSSLCA = $aPreviousInstance['db_ssl_ca']; + $sSSLCaPath = $aPreviousInstance['db_ssl_capath']; + $sSSLCypher = $aPreviousInstance['db_ssl_cipher']; $this->oWizard->SaveParameter('graphviz_path', $aPreviousInstance['graphviz_path']); $sStyle = ''; $sPreviousVersionDir = APPROOT; @@ -244,8 +259,10 @@ class WizStepInstallOrUpgrade extends WizardStep //$oPage->add('
'); //$oPage->add('Information about the previous instance:'); $oPage->add(''); - $oPage->add(''); - SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix); + $oPage->add(''); + SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sSSLKey, + $sSSLCert, $sSSLCA, $sSSLCaPath, $sSSLCypher, null); $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath); $bCanBackup = true; @@ -623,7 +640,12 @@ EOF 'cron'.$this->oWizard->GetParameter('db_name', '').$this->oWizard->GetParameter('db_prefix', ''), $this->oWizard->GetParameter('db_server', ''), $this->oWizard->GetParameter('db_user', ''), - $this->oWizard->GetParameter('db_pwd', '') + $this->oWizard->GetParameter('db_pwd', ''), + $this->oWizard->GetParameter('db_ssl_key', ''), + $this->oWizard->GetParameter('db_ssl_cert', ''), + $this->oWizard->GetParameter('db_ssl_ca', ''), + $this->oWizard->GetParameter('db_ssl_capath', ''), + $this->oWizard->GetParameter('db_ssl_cypher', '') ); if ($oMutex->IsLocked()) { @@ -757,7 +779,12 @@ class WizStepDBParams extends WizardStep $this->oWizard->SaveParameter('new_db_name', ''); $this->oWizard->SaveParameter('create_db', ''); $this->oWizard->SaveParameter('db_new_name', ''); - + $this->oWizard->SaveParameter('db_ssl_key', ''); + $this->oWizard->SaveParameter('db_ssl_cert', ''); + $this->oWizard->SaveParameter('db_ssl_ca', ''); + $this->oWizard->SaveParameter('db_ssl_capath', ''); + $this->oWizard->SaveParameter('db_ssl_cipher', ''); + return array('class' => 'WizStepAdminAccount', 'state' => ''); } @@ -770,9 +797,15 @@ class WizStepDBParams extends WizardStep $sDBName = $this->oWizard->GetParameter('db_name', ''); $sDBPrefix = $this->oWizard->GetParameter('db_prefix', ''); $sNewDBName = $this->oWizard->GetParameter('db_new_name', false); - + $sSSLKey = $this->oWizard->GetParameter('db_ssl_key', ''); + $sSSLCert = $this->oWizard->GetParameter('db_ssl_cert', ''); + $sSSLCA = $this->oWizard->GetParameter('db_ssl_ca', ''); + $sSSLCaPath = $this->oWizard->GetParameter('db_ssl_capath', ''); + $sSSLCypher = $this->oWizard->GetParameter('db_ssl_cipher', ''); + $oPage->add('
Location on the disk:
Location on the disk:
'); - SetupUtils::DisplayDBParameters($oPage, true, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sNewDBName); + SetupUtils::DisplayDBParameters($oPage, true, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sSSLKey, + $sSSLCert, $sSSLCA, $sSSLCaPath, $sSSLCypher, $sNewDBName); $oPage->add('
'); $sCreateDB = $this->oWizard->GetParameter('create_db', 'yes'); if ($sCreateDB == 'no') @@ -1208,14 +1241,27 @@ class WizStepModulesChoice extends WizardStep { $sConfigPath = utils::GetConfigFilePath('production'); } - if ($sConfigPath !== null) - { - $oConfig = new Config($sConfigPath); - $this->bChoicesFromDatabase = $this->oExtensionsMap->LoadChoicesFromDatabase($oConfig); - } + + $oConfig = ($sConfigPath !== null) ? new Config($sConfigPath) : new Config(); + // setting values from the wizard data, as the config file has not been saved yet + $aParamValues = array( + 'db_server' => $this->oWizard->GetParameter('db_server', ''), + 'db_user' => $this->oWizard->GetParameter('db_user', ''), + 'db_pwd' => $this->oWizard->GetParameter('db_pwd', ''), + 'db_name' => $this->oWizard->GetParameter('db_name', ''), + 'db_prefix' => $this->oWizard->GetParameter('db_prefix', ''), + 'db_ssl_key' => $this->oWizard->GetParameter('db_ssl_key', ''), + 'db_ssl_cert' => $this->oWizard->GetParameter('db_ssl_cert', ''), + 'db_ssl_ca' => $this->oWizard->GetParameter('db_ssl_ca', ''), + 'db_ssl_capath' => $this->oWizard->GetParameter('db_ssl_capath', ''), + 'db_ssl_cipher' => $this->oWizard->GetParameter('db_ssl_cipher', ''), + ); + + $oConfig->UpdateFromParams($aParamValues); + $this->bChoicesFromDatabase = $this->oExtensionsMap->LoadChoicesFromDatabase($oConfig); //echo '
Default: '.($this->bChoicesFromDatabase ? 'DB' : 'Guess').'
'; } - + public function GetTitle() { $aStepInfo = $this->GetStepInfo(); @@ -2312,6 +2358,11 @@ EOF 'user' => $this->oWizard->GetParameter('db_user'), 'pwd' => $this->oWizard->GetParameter('db_pwd'), 'name' => $sDBName, + 'db_ssl_key' => $this->oWizard->GetParameter('db_ssl_key'), + 'db_ssl_cert' => $this->oWizard->GetParameter('db_ssl_cert'), + 'db_ssl_ca' => $this->oWizard->GetParameter('db_ssl_ca'), + 'db_ssl_capath' => $this->oWizard->GetParameter('db_ssl_capath'), + 'db_ssl_cipher' => $this->oWizard->GetParameter('db_ssl_cipher'), 'prefix' => $this->oWizard->GetParameter('db_prefix'), ), 'url' => $this->oWizard->GetParameter('application_url'),