/** * check if the current server configuration is suitable for ownCloud * * @param \OCP\IConfig $config * @return array arrays with error messages and hints */ public static function checkServer(\OCP\IConfig $config) { $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data'); if (!self::needUpgrade($config) && $config->getSystemValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } // Assume that if checkServer() succeeded before in this session, then all is fine. if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { return $errors; } $webServerRestart = false; $setup = new OC_Setup($config); $availableDatabases = $setup->getSupportedDatabases(); if (empty($availableDatabases)) { $errors[] = array( 'error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), 'hint' => '' //TODO: sane hint ); $webServerRestart = true; } //common hint for all file permissions error messages $permissionsHint = $l->t('Permissions can usually be fixed by ' . '%sgiving the webserver write access to the root directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); // Check if config folder is writable. if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array( 'error' => $l->t('Cannot write into "config" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) ); } // Check if there is a writable install folder. if ($config->getSystemValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath()) ) { $errors[] = array( 'error' => $l->t('Cannot write into "apps" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the apps directory%s' . ' or disabling the appstore in the config file.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) ); } } // Create root dir. if ($config->getSystemValue('installed', false)) { if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { $errors[] = array( 'error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)), 'hint' => $l->t('This can usually be fixed by ' . '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.', array(OC_Helper::linkToDocs('admin-dir_permissions'))) ); } } else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { $errors[] = array( 'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint ); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } } if (!OC_Util::isSetLocaleWorking()) { $errors[] = array( 'error' => $l->t('Setting locale to %s failed', array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.') ); } // Contains the dependencies that should be checked against // classes = class_exists // functions = function_exists // defined = defined // If the dependency is not found the missing module name is shown to the EndUser $dependencies = array( 'classes' => array( 'ZipArchive' => 'zip', 'DOMDocument' => 'dom', 'XMLWriter' => 'XMLWriter' ), 'functions' => array( 'xml_parser_create' => 'libxml', 'mb_detect_encoding' => 'mb multibyte', 'ctype_digit' => 'ctype', 'json_encode' => 'JSON', 'gd_info' => 'GD', 'gzencode' => 'zlib', 'iconv' => 'iconv', 'simplexml_load_string' => 'SimpleXML', 'hash' => 'HASH Message Digest Framework' ), 'defined' => array( 'PDO::ATTR_DRIVER_NAME' => 'PDO' ) ); $missingDependencies = array(); $moduleHint = $l->t('Please ask your server administrator to install the module.'); foreach ($dependencies['classes'] as $class => $module) { if (!class_exists($class)) { $missingDependencies[] = $module; } } foreach ($dependencies['functions'] as $function => $module) { if (!function_exists($function)) { $missingDependencies[] = $module; } } foreach ($dependencies['defined'] as $defined => $module) { if (!defined($defined)) { $missingDependencies[] = $module; } } foreach($missingDependencies as $missingDependency) { $errors[] = array( 'error' => $l->t('PHP module %s not installed.', array($missingDependency)), 'hint' => $moduleHint ); $webServerRestart = true; } if (version_compare(phpversion(), '5.4.0', '<')) { $errors[] = array( 'error' => $l->t('PHP %s or higher is required.', '5.4.0'), 'hint' => $l->t('Please ask your server administrator to update PHP to the latest version.' . ' Your PHP version is no longer supported by ownCloud and the PHP community.') ); $webServerRestart = true; } /** * PHP 5.6 ships with a PHP setting which throws notices by default for a * lot of endpoints. Thus we need to ensure that the value is set to -1 * * FIXME: Due to https://github.com/owncloud/core/pull/13593#issuecomment-71178078 * this check is disabled for HHVM at the moment. This should get re-evaluated * at a later point. * * @link https://github.com/owncloud/core/issues/13592 */ if(version_compare(phpversion(), '5.6.0', '>=') && !self::runningOnHhvm() && \OC::$server->getIniWrapper()->getNumeric('always_populate_raw_post_data') !== -1) { $errors[] = array( 'error' => $l->t('PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for perfectly valid code.'), 'hint' => $l->t('To fix this issue set <code>always_populate_raw_post_data</code> to <code>-1</code> in your php.ini') ); } if (!self::isAnnotationsWorking()) { $errors[] = array( 'error' => $l->t('PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible.'), 'hint' => $l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.') ); } if ($webServerRestart) { $errors[] = array( 'error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), 'hint' => $l->t('Please ask your server administrator to restart the web server.') ); } $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); return $errors; }
/** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * * @param string $currentVersion current version to upgrade to * @param string $installedVersion previous version from which to upgrade from * * @throws \Exception * @return bool true if the operation succeeded, false otherwise */ private function doUpgrade($currentVersion, $installedVersion) { // Stop update if the update is over several major versions if (!self::isUpgradePossible($installedVersion, $currentVersion)) { throw new \Exception('Updates between multiple major versions are unsupported.'); } // Update htaccess files for apache hosts if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { \OC_Setup::updateHtaccess(); } // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); /* * START CONFIG CHANGES FOR OLDER VERSIONS */ if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) { // Add the trusted_domains config if it is not existant // This is added to prevent host header poisoning \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost()))); } /* * STOP CONFIG CHANGES FOR OLDER VERSIONS */ // pre-upgrade repairs $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps()); $repair->run(); // simulate DB upgrade if ($this->simulateStepEnabled) { $this->checkCoreUpgrade(); // simulate apps DB upgrade $this->checkAppUpgrade($currentVersion); } // upgrade from OC6 to OC7 // TODO removed it again for OC8 $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); if ($sharePolicy === 'groups_only') { \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes'); } if ($this->updateStepEnabled) { $this->doCoreUpgrade(); $disabledApps = \OC_App::checkAppsRequirements(); if (!empty($disabledApps)) { $this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps)); } $this->doAppUpgrade(); // post-upgrade repairs $repair = new \OC\Repair(\OC\Repair::getRepairSteps()); $repair->run(); //Invalidate update feed \OC_Appconfig::setValue('core', 'lastupdatedat', 0); // only set the final version if everything went well \OC_Config::setValue('version', implode('.', \OC_Util::getVersion())); } }
/** * Gathers system information like database type and does * a few system checks. * * @return array of system info, including an "errors" value * in case of errors/warnings */ public function getSystemInfo() { $setup = new \OC_Setup($this->config); $databases = $setup->getSupportedDatabases(); $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); $vulnerableToNullByte = false; if (@file_exists(__FILE__ . "Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243) $vulnerableToNullByte = true; } $errors = array(); // Create data directory to test whether the .htaccess works // Notice that this is not necessarily the same data directory as the one // that will effectively be used. @mkdir($dataDir); $htAccessWorking = true; if (is_dir($dataDir) && is_writable($dataDir)) { // Protect data directory here, so we can test if the protection is working \OC_Setup::protectDataDirectory(); try { $htAccessWorking = \OC_Util::isHtaccessWorking(); } catch (\OC\HintException $e) { $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint()); $htAccessWorking = false; } } if (\OC_Util::runningOnMac()) { $errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')); } if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) { $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.')); } if (!function_exists('curl_init') && PHP_INT_SIZE === 4) { $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32-bit PHP environment and cURL is not installed. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.')); } return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'hasMSSQL' => isset($databases['mssql']), 'databases' => $databases, 'directory' => $dataDir, 'htaccessWorking' => $htAccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors); }
} OC_Util::addScript('setup'); $hasSQLite = class_exists('SQLite3'); $hasMySQL = is_callable('mysql_connect'); $hasPostgreSQL = is_callable('pg_connect'); $hasOracle = is_callable('oci_connect'); $hasMSSQL = is_callable('sqlsrv_connect'); $datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data'); $vulnerableToNullByte = false; if (@file_exists(__FILE__ . "Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243) $vulnerableToNullByte = true; } // Protect data directory here, so we can test if the protection is working OC_Setup::protectDataDirectory(); $opts = array('hasSQLite' => $hasSQLite, 'hasMySQL' => $hasMySQL, 'hasPostgreSQL' => $hasPostgreSQL, 'hasOracle' => $hasOracle, 'hasMSSQL' => $hasMSSQL, 'directory' => $datadir, 'secureRNG' => OC_Util::secureRNGAvailable(), 'htaccessWorking' => OC_Util::isHtAccessWorking(), 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => array(), 'dbIsSet' => $dbIsSet, 'directoryIsSet' => $directoryIsSet); if (isset($_POST['install']) and $_POST['install'] == 'true') { // We have to launch the installation process : $e = OC_Setup::install($_POST); $errors = array('errors' => $e); if (count($e) > 0) { //OC_Template::printGuestPage("", "error", array("errors" => $errors)); $options = array_merge($_POST, $opts, $errors); OC_Template::printGuestPage("", "installation", $options); } else { header('Location: ' . OC_Helper::linkToRoute('post_setup_check')); exit; } } else { OC_Template::printGuestPage("", "installation", $opts); }
/** * Gathers system information like database type and does * a few system checks. * * @return array of system info, including an "errors" value * in case of errors/warnings */ public function getSystemInfo() { $hasSQLite = class_exists('SQLite3'); $hasMySQL = is_callable('mysql_connect'); $hasPostgreSQL = is_callable('pg_connect'); $hasOracle = is_callable('oci_connect'); $hasMSSQL = is_callable('sqlsrv_connect'); $databases = array(); if ($hasSQLite) { $databases['sqlite'] = 'SQLite'; } if ($hasMySQL) { $databases['mysql'] = 'MySQL/MariaDB'; } if ($hasPostgreSQL) { $databases['pgsql'] = 'PostgreSQL'; } if ($hasOracle) { $databases['oci'] = 'Oracle'; } if ($hasMSSQL) { $databases['mssql'] = 'MS SQL'; } $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data'); $vulnerableToNullByte = false; if (@file_exists(__FILE__ . "Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243) $vulnerableToNullByte = true; } $errors = array(); // Protect data directory here, so we can test if the protection is working \OC_Setup::protectDataDirectory(); try { $htaccessWorking = \OC_Util::isHtaccessWorking(); } catch (\OC\HintException $e) { $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint()); $htaccessWorking = false; } if (\OC_Util::runningOnMac()) { $l10n = \OC::$server->getL10N('core'); $themeName = \OC_Util::getTheme(); $theme = new \OC_Defaults(); $errors[] = array('error' => $l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $theme->getName()), 'hint' => $l10n->t('For the best results, please consider using a GNU/Linux server instead.')); } return array('hasSQLite' => $hasSQLite, 'hasMySQL' => $hasMySQL, 'hasPostgreSQL' => $hasPostgreSQL, 'hasOracle' => $hasOracle, 'hasMSSQL' => $hasMSSQL, 'databases' => $databases, 'directory' => $datadir, 'htaccessWorking' => $htaccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors); }
/** * @expectedException \Exception * @expectedExceptionMessage Supported databases are not properly configured. */ public function testGetSupportedDatabaseException() { $this->config->expects($this->once())->method('getSystemValue')->will($this->returnValue('NotAnArray')); $this->setupClass->getSupportedDatabases(); }
/** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * * @param string $currentVersion current version to upgrade to * @param string $installedVersion previous version from which to upgrade from * * @throws \Exception * @return bool true if the operation succeeded, false otherwise */ private function doUpgrade($currentVersion, $installedVersion) { // Stop update if the update is over several major versions if (!self::isUpgradePossible($installedVersion, $currentVersion)) { throw new \Exception('Updates between multiple major versions are unsupported.'); } // Update htaccess files for apache hosts if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { try { \OC_Setup::updateHtaccess(); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } } // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); // pre-upgrade repairs $repair = new Repair(Repair::getBeforeUpgradeRepairSteps()); $this->emitRepairMessages($repair); $repair->run(); // simulate DB upgrade if ($this->simulateStepEnabled) { $this->checkCoreUpgrade(); // simulate apps DB upgrade $this->checkAppUpgrade($currentVersion); } if ($this->updateStepEnabled) { $this->doCoreUpgrade(); $this->checkAppsRequirements(); $this->doAppUpgrade(); // post-upgrade repairs $repair = new Repair(Repair::getRepairSteps()); $this->emitRepairMessages($repair); $repair->run(); //Invalidate update feed $this->config->setAppValue('core', 'lastupdatedat', 0); // only set the final version if everything went well $this->config->setSystemValue('version', implode('.', \OC_Util::getVersion())); } }
/** * Append the correct ErrorDocument path for Apache hosts * * @throws \OC\HintException If .htaccess does not include the current version */ public static function updateHtaccess() { $setupHelper = new OC_Setup(\OC::$server->getConfig()); if (!$setupHelper->isCurrentHtaccess()) { throw new \OC\HintException('.htaccess file has the wrong version. Please upload the correct version. Maybe you forgot to replace it after updating?'); } $content = "\n"; $content .= "ErrorDocument 403 " . OC::$WEBROOT . "/core/templates/403.php\n"; //custom 403 error page $content .= "ErrorDocument 404 " . OC::$WEBROOT . "/core/templates/404.php"; //custom 404 error page @file_put_contents($setupHelper->pathToHtaccess(), $content, FILE_APPEND); //suppress errors in case we don't have permissions for it }
/** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * * @param string $currentVersion current version to upgrade to * @param string $installedVersion previous version from which to upgrade from * * @return bool true if the operation succeeded, false otherwise */ private function doUpgrade($currentVersion, $installedVersion) { // Update htaccess files for apache hosts if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { \OC_Setup::updateHtaccess(); } // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); /* * START CONFIG CHANGES FOR OLDER VERSIONS */ if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) { // Add the trusted_domains config if it is not existant // This is added to prevent host header poisoning \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost()))); } /* * STOP CONFIG CHANGES FOR OLDER VERSIONS */ // pre-upgrade repairs $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps()); $repair->run(); // simulate DB upgrade if ($this->simulateStepEnabled) { // simulate core DB upgrade \OC_DB::simulateUpdateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); // simulate apps DB upgrade $version = \OC_Util::getVersion(); $apps = \OC_App::getEnabledApps(); foreach ($apps as $appId) { $info = \OC_App::getAppInfo($appId); if (\OC_App::isAppCompatible($version, $info) && \OC_App::shouldUpgrade($appId)) { if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); } } } $this->emit('\\OC\\Updater', 'dbSimulateUpgrade'); } // upgrade from OC6 to OC7 // TODO removed it again for OC8 $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); if ($sharePolicy === 'groups_only') { \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes'); } if ($this->updateStepEnabled) { // do the real upgrade \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); $this->emit('\\OC\\Updater', 'dbUpgrade'); // TODO: why not do this at the end ? \OC_Config::setValue('version', implode('.', \OC_Util::getVersion())); $disabledApps = \OC_App::checkAppsRequirements(); if (!empty($disabledApps)) { $this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps)); } // load all apps to also upgrade enabled apps \OC_App::loadApps(); // post-upgrade repairs $repair = new \OC\Repair(\OC\Repair::getRepairSteps()); $repair->run(); //Invalidate update feed \OC_Appconfig::setValue('core', 'lastupdatedat', 0); } }
/** * check if the current server configuration is suitable for ownCloud * * @param \OCP\IConfig $config * @return array arrays with error messages and hints */ public static function checkServer($config) { $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data'); if (!self::needUpgrade($config) && $config->getSystemValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } // Assume that if checkServer() succeeded before in this session, then all is fine. if (\OC::$session->exists('checkServer_succeeded') && \OC::$session->get('checkServer_succeeded')) { return $errors; } $webServerRestart = false; $setup = new OC_Setup($config); $availableDatabases = $setup->getSupportedDatabases(); if (empty($availableDatabases)) { $errors[] = array('error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), 'hint' => ''); $webServerRestart = true; } // Check if config folder is writable. if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array('error' => $l->t('Cannot write into "config" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))); } // Check if there is a writable install folder. if ($config->getSystemValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath())) { $errors[] = array('error' => $l->t('Cannot write into "apps" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the apps directory%s' . ' or disabling the appstore in the config file.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))); } } // Create root dir. if ($config->getSystemValue('installed', false)) { if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { $errors[] = array('error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)), 'hint' => $l->t('This can usually be fixed by ' . '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.', array(OC_Helper::linkToDocs('admin-dir_permissions')))); } } else { if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { //common hint for all file permissions error messages $permissionsHint = $l->t('Permissions can usually be fixed by ' . '%sgiving the webserver write access to the root directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } } } if (!OC_Util::isSetLocaleWorking()) { $errors[] = array('error' => $l->t('Setting locale to %s failed', array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), 'hint' => $l->t('Please install one of theses locales on your system and restart your webserver.')); } $moduleHint = $l->t('Please ask your server administrator to install the module.'); // check if all required php modules are present if (!class_exists('ZipArchive')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('zip')), 'hint' => $moduleHint); $webServerRestart = true; } if (!class_exists('XMLWriter')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('XMLWriter')), 'hint' => $moduleHint); $webServerRestart = true; } if (!class_exists('DOMDocument')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('dom')), 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('xml_parser_create')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('libxml')), 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('mb_detect_encoding')) { $errors[] = array('error' => 'PHP module mb multibyte not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('ctype_digit')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('ctype')), 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('json_encode')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('JSON')), 'hint' => $moduleHint); $webServerRestart = true; } if (!extension_loaded('gd') || !function_exists('gd_info')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('GD')), 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('gzencode')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('zlib')), 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('iconv')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('iconv')), 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('simplexml_load_string')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('SimpleXML')), 'hint' => $moduleHint); $webServerRestart = true; } if (version_compare(phpversion(), '5.3.3', '<')) { $errors[] = array('error' => $l->t('PHP %s or higher is required.', '5.3.3'), 'hint' => $l->t('Please ask your server administrator to update PHP to the latest version.' . ' Your PHP version is no longer supported by ownCloud and the PHP community.')); $webServerRestart = true; } if (!defined('PDO::ATTR_DRIVER_NAME')) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array('PDO')), 'hint' => $moduleHint); $webServerRestart = true; } if (strtolower(@ini_get('safe_mode')) == 'on' || strtolower(@ini_get('safe_mode')) == 'yes' || strtolower(@ini_get('safe_mode')) == 'true' || ini_get("safe_mode") == 1) { $errors[] = array('error' => $l->t('PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.'), 'hint' => $l->t('PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. ' . 'Please ask your server administrator to disable it in php.ini or in your webserver config.')); $webServerRestart = true; } if (get_magic_quotes_gpc() == 1) { $errors[] = array('error' => $l->t('Magic Quotes is enabled. ownCloud requires that it is disabled to work properly.'), 'hint' => $l->t('Magic Quotes is a deprecated and mostly useless setting that should be disabled. ' . 'Please ask your server administrator to disable it in php.ini or in your webserver config.')); $webServerRestart = true; } if (!self::isAnnotationsWorking()) { $errors[] = array('error' => 'PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible.', 'hint' => 'This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.'); } if ($webServerRestart) { $errors[] = array('error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), 'hint' => $l->t('Please ask your server administrator to restart the web server.')); } $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function \OC::$session->set('checkServer_succeeded', count($errors) == 0); return $errors; }
/** * Gathers system information like database type and does * a few system checks. * * @return array of system info, including an "errors" value * in case of errors/warnings */ public function getSystemInfo() { $setup = new \OC_Setup($this->config); $databases = $setup->getSupportedDatabases(); $datadir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); $vulnerableToNullByte = false; if (@file_exists(__FILE__ . "Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243) $vulnerableToNullByte = true; } $errors = array(); // Create data directory to test whether the .htaccess works // Notice that this is not necessarily the same data directory as the one // that will effectively be used. @mkdir($datadir); if (is_dir($datadir) && is_writable($datadir)) { // Protect data directory here, so we can test if the protection is working \OC_Setup::protectDataDirectory(); try { $htaccessWorking = \OC_Util::isHtaccessWorking(); } catch (\OC\HintException $e) { $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint()); $htaccessWorking = false; } } if (\OC_Util::runningOnMac()) { $l10n = \OC_L10N::get('core'); $themeName = \OC_Util::getTheme(); $theme = new \OC_Defaults(); $errors[] = array('error' => $l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $theme->getName()), 'hint' => $l10n->t('For the best results, please consider using a GNU/Linux server instead.')); } return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'hasMSSQL' => isset($databases['mssql']), 'databases' => $databases, 'directory' => $datadir, 'secureRNG' => \OC_Util::secureRNGAvailable(), 'htaccessWorking' => $htaccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors); }
public static function checkUpgrade() { if (OC_Config::getValue('installed', false)) { $installedVersion = OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', OC_Util::getVersion()); if (version_compare($currentVersion, $installedVersion, '>')) { // Check if the .htaccess is existing - this is needed for upgrades from really old ownCloud versions if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { if (!OC_Util::ishtaccessworking()) { if (!file_exists(OC::$SERVERROOT . '/data/.htaccess')) { OC_Setup::protectDataDirectory(); } } } OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG); $result = OC_DB::updateDbFromStructure(OC::$SERVERROOT . '/db_structure.xml'); if (!$result) { echo 'Error while upgrading the database'; die; } if (file_exists(OC::$SERVERROOT . "/config/config.php") and !is_writable(OC::$SERVERROOT . "/config/config.php")) { $tmpl = new OC_Template('', 'error', 'guest'); $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); $tmpl->printPage(); exit; } $minimizerCSS = new OC_Minimizer_CSS(); $minimizerCSS->clearCache(); $minimizerJS = new OC_Minimizer_JS(); $minimizerJS->clearCache(); OC_Config::setValue('version', implode('.', OC_Util::getVersion())); OC_App::checkAppsRequirements(); // load all apps to also upgrade enabled apps OC_App::loadApps(); } } }