N°1260 MySQL TLS connection : add options in setup

SVN:trunk[5311]
This commit is contained in:
Pierre Goiffon
2018-02-08 14:21:51 +00:00
parent 3375629d06
commit 5a2576bc29
8 changed files with 608 additions and 348 deletions

View File

@@ -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)

View File

@@ -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']);
}
}
/**

View File

@@ -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)
{

View File

@@ -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("|<pwd>([^<]*)</pwd>|", "<pwd>**removed**</pwd>", $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("|<pwd>([^<]*)</pwd>|", "<pwd>**removed**</pwd>", $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);

View File

@@ -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;
}

View File

@@ -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('<tr><td colspan="2">');
$oPage->add('<fieldset><legend>Database Server Connection</legend>');
$oPage->add('<table>');
$oPage->add('<table id="table_db_options">');
//-- DB connection params
$oPage->add('<tbody>');
$oPage->add('<tr><td>Server Name:</td><td><input id="db_server" type="text" name="db_server" value="'.htmlentities($sDBServer, ENT_QUOTES, 'UTF-8').'" size="15"/></td><td>E.g. "localhost", "dbserver.mycompany.com" or "192.142.10.23"</td></tr>');
$oPage->add('<tr><td>Login:</td><td><input id="db_user" type="text" name="db_user" value="'.htmlentities($sDBUser, ENT_QUOTES, 'UTF-8').'" size="15"/></td><td rowspan="2" style="vertical-align:top">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</td></tr>');
$oPage->add('<tr><td>Password:</td><td><input id="db_pwd" autocomplete="off" type="password" name="db_pwd" value="'.htmlentities($sDBPwd, ENT_QUOTES, 'UTF-8').'" size="15"/></td></tr>');
$oPage->add('</tbody>');
//-- SSL params (N°1260)
$oPage->add('<tbody id="ssl_options">');
$oPage->add('<tr><th colspan="3"><label><img id="db_ssl_img"> Connect using SSL</label></th></tr>');
$oPage->add('<tr><td colspan="3" style="font-weight: bold; background-color: #f97e75; padding: 1em;">Warning: please make sure of all the system requirements, and test the connection using the simple test page available <a href="https://wiki.openitop.org/doku.php?id=2_4_0:install:php_and_mysql_tls">on Combodo\'s Wiki</a></td>');
$oPage->add('<tr><td>SSL Key:</td>');
$oPage->add('<td><input id="db_ssl_key" autocomplete="off" type="text" name="db_ssl_key" value="'.htmlentities($sSSLKey,
ENT_QUOTES, 'UTF-8').'" size="15"/></td>');
$oPage->add('<td>Path to client key file for SSL</td></tr>');
$oPage->add('<tr><td>SSL CERT:</td>');
$oPage->add('<td><input id="db_ssl_cert" autocomplete="off" type="text" name="db_ssl_cert" value="'.htmlentities($sSSLCert,
ENT_QUOTES, 'UTF-8').'" size="15"/></td>');
$oPage->add('<td>Path to client certificate file for SSL</td></tr>');
$oPage->add('<tr><td>SSL CA:</td>');
$oPage->add('<td><input id="db_ssl_ca" autocomplete="off" type="text" name="db_ssl_ca" value="'.htmlentities($sSSLCA,
ENT_QUOTES, 'UTF-8').'" size="15"/></td>');
$oPage->add('<td>Path to certificate authority file for SSL</td></tr>');
$oPage->add('<tr><td>SSL CA path:</td>');
$oPage->add('<td><input id="db_ssl_capath" autocomplete="off" type="text" name="db_ssl_capath" value="'.htmlentities($sSSLCaPath,
ENT_QUOTES, 'UTF-8').'" size="15"/></td>');
$oPage->add('<td></td></td></tr>');
$oPage->add('<tr><td>SSL cypher:</td>');
$oPage->add('<td><input id="db_ssl_cipher" autocomplete="off" type="text" name="db_ssl_cipher" value="'.htmlentities($sSSLCypher,
ENT_QUOTES, 'UTF-8').'" size="15"/></td>');
$oPage->add('<td>Optional : separated list of permissible cyphers to use for SSL encryption</td></tr>');
$oPage->add('</tbody>');
$oPage->add('</table>');
$oPage->add('</fieldset>');
$oPage->add('</td></tr>');
@@ -893,6 +953,37 @@ class SetupUtils
$oPage->add('</fieldset>');
$oPage->add('<tr><td colspan="2"><span id="table_info">&nbsp;</span></td></tr>');
$oPage->add('</td></tr>');
// 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(
<<<EOF
$("tbody#ssl_options>tr>th>label").click(function() {
toggleSslOptions();
});
updateSslImage();
EOF
);
$oPage->add_script(
<<<EOF
var iCheckDBTimer = null;
@@ -916,7 +1007,12 @@ function DoCheckDBConnection()
'db_server': $("#db_server").val(),
'db_user': $("#db_user").val(),
'db_pwd': $("#db_pwd").val(),
'db_name': $("#db_name").val()
'db_name': $("#db_name").val(),
'db_ssl_key': $("input#db_ssl_key").val(),
'db_ssl_cert': $("input#db_ssl_cert").val(),
'db_ssl_ca': $("input#db_ssl_ca").val(),
'db_ssl_capath': $("input#db_ssl_capath").val(),
'db_ssl_cypher': $("input#db_ssl_cypher").val()
}
if ((oXHRCheckDB != null) && (oXHRCheckDB != undefined))
{
@@ -1004,32 +1100,57 @@ EOF
<<<EOF
DoCheckDBConnection(); // Validate the initial values immediately
$("#db_server").bind("keyup change", function() { CheckDBConnection(); });
$("#db_user").bind("keyup change", function() { CheckDBConnection(); });
$("#db_pwd").bind("keyup change", function() { CheckDBConnection(); });
$("#db_new_name").bind("click keyup change", function() { $("#create_db").attr("checked", "checked"); WizardUpdateButtons(); });
$("#db_name").bind("click keyup change", function() { $("#existing_db").attr("checked", "checked"); WizardUpdateButtons(); });
$("#db_prefix").bind("keyup change", function() { WizardUpdateButtons(); });
$("#existing_db").bind("click change", function() { WizardUpdateButtons(); });
$("#create_db").bind("click change", function() { WizardUpdateButtons(); });
$("table#table_db_options").on("keyup change", "tr>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);

View File

@@ -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))
{

View File

@@ -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('<fieldset id="upgrade_info"'.$sUpgradeInfoStyle.'>');
//$oPage->add('<legend>Information about the previous instance:</legend>');
$oPage->add('<table id="upgrade_info"'.$sUpgradeInfoStyle.'>');
$oPage->add('<tr><td>Location on the disk:</td><td><input id="previous_version_dir" type="text" name="previous_version_dir" value="'.htmlentities($sPreviousVersionDir, ENT_QUOTES, 'UTF-8').'" size="25"/></td></tr>');
SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix);
$oPage->add('<tr><td>Location on the disk:</td><td><input id="previous_version_dir" type="text" name="previous_version_dir" value="'.htmlentities($sPreviousVersionDir,
ENT_QUOTES, 'UTF-8').'" style="width: 98%;"/></td></tr>');
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('<table>');
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('</table>');
$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 '<div style="display:block;position:fixed;width:100px;height:20px;top:0;left:0;font-size:10pt;">Default: '.($this->bChoicesFromDatabase ? 'DB' : 'Guess').'</div>';
}
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'),