code cleanup during review 👍
This commit is contained in:
parent
233c49f4b9
commit
79778d6a51
|
@ -103,7 +103,7 @@ class Controller {
|
||||||
$setup = new \OC_Setup($this->config);
|
$setup = new \OC_Setup($this->config);
|
||||||
$databases = $setup->getSupportedDatabases();
|
$databases = $setup->getSupportedDatabases();
|
||||||
|
|
||||||
$datadir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
|
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
|
||||||
$vulnerableToNullByte = false;
|
$vulnerableToNullByte = false;
|
||||||
if(@file_exists(__FILE__."\0Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
|
if(@file_exists(__FILE__."\0Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
|
||||||
$vulnerableToNullByte = true;
|
$vulnerableToNullByte = true;
|
||||||
|
@ -114,25 +114,25 @@ class Controller {
|
||||||
// Create data directory to test whether the .htaccess works
|
// Create data directory to test whether the .htaccess works
|
||||||
// Notice that this is not necessarily the same data directory as the one
|
// Notice that this is not necessarily the same data directory as the one
|
||||||
// that will effectively be used.
|
// that will effectively be used.
|
||||||
@mkdir($datadir);
|
@mkdir($dataDir);
|
||||||
if (is_dir($datadir) && is_writable($datadir)) {
|
$htAccessWorking = true;
|
||||||
|
if (is_dir($dataDir) && is_writable($dataDir)) {
|
||||||
// Protect data directory here, so we can test if the protection is working
|
// Protect data directory here, so we can test if the protection is working
|
||||||
\OC_Setup::protectDataDirectory();
|
\OC_Setup::protectDataDirectory();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$htaccessWorking = \OC_Util::isHtaccessWorking();
|
$htAccessWorking = \OC_Util::isHtaccessWorking();
|
||||||
} catch (\OC\HintException $e) {
|
} catch (\OC\HintException $e) {
|
||||||
$errors[] = array(
|
$errors[] = array(
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
'hint' => $e->getHint()
|
'hint' => $e->getHint()
|
||||||
);
|
);
|
||||||
$htaccessWorking = false;
|
$htAccessWorking = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\OC_Util::runningOnMac()) {
|
if (\OC_Util::runningOnMac()) {
|
||||||
$l10n = \OC::$server->getL10N('core');
|
$l10n = \OC::$server->getL10N('core');
|
||||||
$themeName = \OC_Util::getTheme();
|
|
||||||
$theme = new \OC_Defaults();
|
$theme = new \OC_Defaults();
|
||||||
$errors[] = array(
|
$errors[] = array(
|
||||||
'error' => $l10n->t(
|
'error' => $l10n->t(
|
||||||
|
@ -151,8 +151,8 @@ class Controller {
|
||||||
'hasOracle' => isset($databases['oci']),
|
'hasOracle' => isset($databases['oci']),
|
||||||
'hasMSSQL' => isset($databases['mssql']),
|
'hasMSSQL' => isset($databases['mssql']),
|
||||||
'databases' => $databases,
|
'databases' => $databases,
|
||||||
'directory' => $datadir,
|
'directory' => $dataDir,
|
||||||
'htaccessWorking' => $htaccessWorking,
|
'htaccessWorking' => $htAccessWorking,
|
||||||
'vulnerableToNullByte' => $vulnerableToNullByte,
|
'vulnerableToNullByte' => $vulnerableToNullByte,
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
);
|
);
|
||||||
|
|
|
@ -90,7 +90,8 @@ class OC_Setup {
|
||||||
'name' => 'MS SQL'
|
'name' => 'MS SQL'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$configuredDatabases = $this->config->getSystemValue('supportedDatabases', array('sqlite', 'mysql', 'pgsql', 'oci', 'mssql'));
|
$configuredDatabases = $this->config->getSystemValue('supportedDatabases',
|
||||||
|
array('sqlite', 'mysql', 'pgsql', 'oci', 'mssql'));
|
||||||
if(!is_array($configuredDatabases)) {
|
if(!is_array($configuredDatabases)) {
|
||||||
throw new Exception('Supported databases are not properly configured.');
|
throw new Exception('Supported databases are not properly configured.');
|
||||||
}
|
}
|
||||||
|
@ -122,7 +123,7 @@ class OC_Setup {
|
||||||
$l = self::getTrans();
|
$l = self::getTrans();
|
||||||
|
|
||||||
$error = array();
|
$error = array();
|
||||||
$dbtype = $options['dbtype'];
|
$dbType = $options['dbtype'];
|
||||||
|
|
||||||
if(empty($options['adminlogin'])) {
|
if(empty($options['adminlogin'])) {
|
||||||
$error[] = $l->t('Set an admin username.');
|
$error[] = $l->t('Set an admin username.');
|
||||||
|
@ -134,25 +135,25 @@ class OC_Setup {
|
||||||
$options['directory'] = OC::$SERVERROOT."/data";
|
$options['directory'] = OC::$SERVERROOT."/data";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$dbSetupClasses[$dbtype])) {
|
if (!isset(self::$dbSetupClasses[$dbType])) {
|
||||||
$dbtype = 'sqlite';
|
$dbType = 'sqlite';
|
||||||
}
|
}
|
||||||
|
|
||||||
$username = htmlspecialchars_decode($options['adminlogin']);
|
$username = htmlspecialchars_decode($options['adminlogin']);
|
||||||
$password = htmlspecialchars_decode($options['adminpass']);
|
$password = htmlspecialchars_decode($options['adminpass']);
|
||||||
$datadir = htmlspecialchars_decode($options['directory']);
|
$dataDir = htmlspecialchars_decode($options['directory']);
|
||||||
|
|
||||||
$class = self::$dbSetupClasses[$dbtype];
|
$class = self::$dbSetupClasses[$dbType];
|
||||||
/** @var \OC\Setup\AbstractDatabase $dbSetup */
|
/** @var \OC\Setup\AbstractDatabase $dbSetup */
|
||||||
$dbSetup = new $class(self::getTrans(), 'db_structure.xml');
|
$dbSetup = new $class(self::getTrans(), 'db_structure.xml');
|
||||||
$error = array_merge($error, $dbSetup->validate($options));
|
$error = array_merge($error, $dbSetup->validate($options));
|
||||||
|
|
||||||
// validate the data directory
|
// validate the data directory
|
||||||
if (
|
if (
|
||||||
(!is_dir($datadir) and !mkdir($datadir)) or
|
(!is_dir($dataDir) and !mkdir($dataDir)) or
|
||||||
!is_writable($datadir)
|
!is_writable($dataDir)
|
||||||
) {
|
) {
|
||||||
$error[] = $l->t("Can't create or write into the data directory %s", array($datadir));
|
$error[] = $l->t("Can't create or write into the data directory %s", array($dataDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($error) != 0) {
|
if(count($error) != 0) {
|
||||||
|
@ -168,12 +169,12 @@ class OC_Setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OC_Util::runningOnWindows()) {
|
if (OC_Util::runningOnWindows()) {
|
||||||
$datadir = rtrim(realpath($datadir), '\\');
|
$dataDir = rtrim(realpath($dataDir), '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
//use sqlite3 when available, otherise sqlite2 will be used.
|
//use sqlite3 when available, otherwise sqlite2 will be used.
|
||||||
if($dbtype=='sqlite' and class_exists('SQLite3')) {
|
if($dbType=='sqlite' and class_exists('SQLite3')) {
|
||||||
$dbtype='sqlite3';
|
$dbType='sqlite3';
|
||||||
}
|
}
|
||||||
|
|
||||||
//generate a random salt that is used to salt the local user passwords
|
//generate a random salt that is used to salt the local user passwords
|
||||||
|
@ -186,9 +187,9 @@ class OC_Setup {
|
||||||
|
|
||||||
//write the config file
|
//write the config file
|
||||||
\OC::$server->getConfig()->setSystemValue('trusted_domains', $trustedDomains);
|
\OC::$server->getConfig()->setSystemValue('trusted_domains', $trustedDomains);
|
||||||
\OC::$server->getConfig()->setSystemValue('datadirectory', $datadir);
|
\OC::$server->getConfig()->setSystemValue('datadirectory', $dataDir);
|
||||||
\OC::$server->getConfig()->setSystemValue('overwrite.cli.url', \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT);
|
\OC::$server->getConfig()->setSystemValue('overwrite.cli.url', \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT);
|
||||||
\OC::$server->getConfig()->setSystemValue('dbtype', $dbtype);
|
\OC::$server->getConfig()->setSystemValue('dbtype', $dbType);
|
||||||
\OC::$server->getConfig()->setSystemValue('version', implode('.', OC_Util::getVersion()));
|
\OC::$server->getConfig()->setSystemValue('version', implode('.', OC_Util::getVersion()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -211,8 +212,7 @@ class OC_Setup {
|
||||||
//create the user and group
|
//create the user and group
|
||||||
try {
|
try {
|
||||||
OC_User::createUser($username, $password);
|
OC_User::createUser($username, $password);
|
||||||
}
|
} catch(Exception $exception) {
|
||||||
catch(Exception $exception) {
|
|
||||||
$error[] = $exception->getMessage();
|
$error[] = $exception->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue