Ejemplo n.º 1
0
 /**
  * Checks a BE/*mask setting for it's security
  *
  * If it permits world writing: Error
  * If it permits world reading: Warning
  * If it permits group writing: Notice
  * If it permits group reading: Notice
  * If it permits only user read/write: Ok
  *
  * @param string $which fileCreateMask or folderCreateMask
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 public function getMaskStatus($which)
 {
     $octal = '0' . $GLOBALS['TYPO3_CONF_VARS']['BE'][$which];
     $dec = octdec($octal);
     $perms = array('ox' => ($dec & 01) == 01, 'ow' => ($dec & 02) == 02, 'or' => ($dec & 04) == 04, 'gx' => ($dec & 010) == 010, 'gw' => ($dec & 020) == 020, 'gr' => ($dec & 040) == 040, 'ux' => ($dec & 0100) == 0100, 'uw' => ($dec & 0200) == 0200, 'ur' => ($dec & 0400) == 0400, 'setgid' => ($dec & 02000) == 02000);
     $extraMessage = '';
     $groupPermissions = FALSE;
     if (!$perms['uw'] || !$perms['ur']) {
         $permissionStatus = new Status\ErrorStatus();
         $extraMessage = ' (not read or writable by the user)';
     } elseif ($perms['ow']) {
         if (TYPO3_OS === 'WIN') {
             $permissionStatus = new Status\InfoStatus();
             $extraMessage = ' (writable by anyone on the server). This is the default behavior on a Windows system';
         } else {
             $permissionStatus = new Status\ErrorStatus();
             $extraMessage = ' (writable by anyone on the server)';
         }
     } elseif ($perms['or']) {
         $permissionStatus = new Status\NoticeStatus();
         $extraMessage = ' (readable by anyone on the server). This is the default set by TYPO3 CMS to be as much compatible as possible but if your system allows, please consider to change rights';
     } elseif ($perms['gw']) {
         $permissionStatus = new Status\OkStatus();
         $extraMessage = ' (group writable)';
         $groupPermissions = TRUE;
     } elseif ($perms['gr']) {
         $permissionStatus = new Status\OkStatus();
         $extraMessage = ' (group readable)';
         $groupPermissions = TRUE;
     } else {
         $permissionStatus = new Status\OkStatus();
     }
     $permissionStatus->setTitle($this->names[$which] . ' (BE/' . $which . ')');
     $message = 'Recommended: ' . $this->recommended[$which] . '.';
     $message .= ' Currently configured as ';
     if ($GLOBALS['TYPO3_CONF_VARS']['BE'][$which] === $this->recommended[$which]) {
         $message .= 'recommended';
     } else {
         $message .= $GLOBALS['TYPO3_CONF_VARS']['BE'][$which];
     }
     $message .= $extraMessage . '.';
     if ($groupPermissions) {
         $message .= ' This is fine as long as the web server\'s group only comprises trusted users.';
         if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'])) {
             $message .= ' Your site is configured (BE/createGroup) to write as group \'' . $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] . '\'.';
         }
     }
     $permissionStatus->setMessage($message);
     return $permissionStatus;
 }
Ejemplo n.º 2
0
 /**
  * Get status of directory - used in root and directory node
  *
  * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
  */
 protected function getSelfStatus()
 {
     $result = array();
     if (!$this->isDirectory()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' is not a directory');
         $status->setMessage('Directory ' . $this->getRelativePathBelowSiteRoot() . ' should be a directory,' . ' but is of type ' . filetype($this->getAbsolutePath()));
         $result[] = $status;
     } elseif (!$this->isWritable()) {
         $status = new Status\ErrorStatus();
         $status->setTitle('Directory ' . $this->getRelativePathBelowSiteRoot() . ' is not writable');
         $status->setMessage('Path ' . $this->getAbsolutePath() . ' exists, but no file underneath it' . ' can be created.');
         $result[] = $status;
     } elseif (!$this->isPermissionCorrect()) {
         $status = new Status\NoticeStatus();
         $status->setTitle('Directory ' . $this->getRelativePathBelowSiteRoot() . ' permissions mismatch');
         $status->setMessage('Default configured permissions are ' . $this->getTargetPermission() . ' but current permissions are ' . $this->getCurrentPermission());
         $result[] = $status;
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('Directory ' . $this->getRelativePathBelowSiteRoot());
         $status->setMessage('Is a directory with the configured permissions of ' . $this->getTargetPermission());
         $result[] = $status;
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Get own status
  * Returns information status if running on Windows
  * Returns OK status if is link and possible target is correct
  * Else returns error (not fixable)
  *
  * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
  */
 public function getStatus()
 {
     if ($this->isWindowsOs()) {
         $status = new Status\InfoStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' should be a link, but this support is incomplete for Windows.');
         $status->setMessage('This node is not handled for Windows OS and should be checked manually.');
         return [$status];
     }
     if (!$this->exists()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' should be a link, but it does not exist');
         $status->setMessage('Links cannot be fixed by this system');
         return [$status];
     }
     if (!$this->isLink()) {
         $status = new Status\WarningStatus();
         $status->setTitle('Path ' . $this->getRelativePathBelowSiteRoot() . ' is not a link');
         $type = @filetype($this->getAbsolutePath());
         if ($type) {
             $status->setMessage('The target ' . $this->getRelativePathBelowSiteRoot() . ' should be a link,' . ' but is of type ' . $type . '. This cannot be fixed automatically. Please investigate.');
         } else {
             $status->setMessage('The target ' . $this->getRelativePathBelowSiteRoot() . ' should be a file,' . ' but is of unknown type, probably because an upper level directory does not exist. Please investigate.');
         }
         return [$status];
     }
     if (!$this->isTargetCorrect()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' is a link, but link target is not as specified');
         $status->setMessage('Link target should be ' . $this->getTarget() . ' but is ' . $this->getCurrentTarget());
         return [$status];
     }
     $status = new Status\OkStatus();
     $message = 'Is a link';
     if ($this->getTarget() !== '') {
         $message .= ' and correctly points to target ' . $this->getTarget();
     }
     $status->setTitle($this->getRelativePathBelowSiteRoot());
     $status->setMessage($message);
     return [$status];
 }
Ejemplo n.º 4
0
 /**
  * Fix permission if they are not equal to target permission
  *
  * @throws Exception
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 protected function fixPermission()
 {
     if ($this->isPermissionCorrect()) {
         throw new Exception('Permission on ' . $this->getAbsolutePath() . ' are already ok', 1366744035);
     }
     $result = @chmod($this->getAbsolutePath(), octdec($this->getTargetPermission()));
     if ($result === TRUE) {
         $status = new Status\OkStatus();
         $status->setTitle('Fixed permission on ' . $this->getRelativePathBelowSiteRoot() . '.');
     } else {
         $status = new Status\NoticeStatus();
         $status->setTitle('Permission change on ' . $this->getRelativePathBelowSiteRoot() . ' not successful');
         $status->setMessage('Permissions could not be changed to ' . $this->getTargetPermission() . '. This only is a problem if files and folders within this node cannot be written.');
     }
     return $status;
 }
Ejemplo n.º 5
0
 /**
  * Checks the character set of the database and reports an error if it is not utf-8.
  *
  * @return Status\StatusInterface
  */
 protected function checkMysqlDatabaseUtf8Status()
 {
     $result = $this->getDatabaseConnection()->admin_query('SHOW VARIABLES LIKE "character_set_database"');
     $row = $this->getDatabaseConnection()->sql_fetch_assoc($result);
     $key = $row['Variable_name'];
     $value = $row['Value'];
     if ($key !== 'character_set_database') {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL database character set check failed');
         $status->setMessage('Checking database character set failed, got key "' . $key . '" instead of "character_set_database"');
     }
     // also allow utf8mb4
     if (substr($value, 0, 4) !== 'utf8') {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL database character set wrong');
         $status->setMessage('Your database uses character set "' . $value . '", but only "utf8" is supported with TYPO3.');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('Your database uses utf-8. All good.');
     }
     return $status;
 }
Ejemplo n.º 6
0
 /**
  * Check minimum MySQL version
  *
  * @return Status\StatusInterface
  */
 protected function checkMysqlVersion()
 {
     $minimumMysqlVersion = '5.5.0';
     $currentMysqlVersion = '';
     $resource = $this->getDatabaseConnection()->sql_query('SHOW VARIABLES LIKE \'version\';');
     if ($resource !== false) {
         $result = $this->getDatabaseConnection()->sql_fetch_row($resource);
         if (isset($result[1])) {
             $currentMysqlVersion = $result[1];
         }
     }
     if (version_compare($currentMysqlVersion, $minimumMysqlVersion) < 0) {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL version too low');
         $status->setMessage('Your MySQL version ' . $currentMysqlVersion . ' is too old. TYPO3 CMS does not run' . ' with this version. Update to at least MySQL ' . $minimumMysqlVersion);
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('MySQL version is fine');
     }
     return $status;
 }
Ejemplo n.º 7
0
 /**
  * Check for bug in libxml
  *
  * @return Status\StatusInterface
  */
 protected function checkLibXmlBug()
 {
     $sampleArray = array('Test>><<Data');
     $xmlContent = '<numIndex index="0">Test&gt;&gt;&lt;&lt;Data</numIndex>' . LF;
     $xml = \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml($sampleArray, '', -1);
     if ($xmlContent !== $xml) {
         $status = new Status\ErrorStatus();
         $status->setTitle('PHP libxml bug present');
         $status->setMessage('Some hosts have problems saving ">><<" in a flexform.' . ' To fix this, enable [BE][flexformForceCDATA] in' . ' All Configuration.');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('PHP libxml bug not present');
     }
     return $status;
 }
Ejemplo n.º 8
0
 /**
  * Sets content of file to target content
  *
  * @throws Exception If file does not exist
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 protected function setContent()
 {
     $absolutePath = $this->getAbsolutePath();
     if (is_link($absolutePath) || !is_file($absolutePath)) {
         throw new Exception('File ' . $absolutePath . ' must exist', 1367060201);
     }
     if (is_null($this->targetContent)) {
         throw new Exception('Target content not defined for ' . $absolutePath, 1367060202);
     }
     $result = @file_put_contents($absolutePath, $this->targetContent);
     if ($result !== false) {
         $status = new Status\OkStatus();
         $status->setTitle('Set content to ' . $this->getRelativePathBelowSiteRoot());
     } else {
         $status = new Status\ErrorStatus();
         $status->setTitle('Setting content to ' . $this->getRelativePathBelowSiteRoot() . ' failed');
         $status->setMessage('Setting content of the file failed for unknown reasons.');
     }
     return $status;
 }
Ejemplo n.º 9
0
 /**
  * Checks the character set of the database and reports an error if it is not utf-8.
  *
  * @param Connection $connection to the database to be checked
  * @return Status\StatusInterface
  */
 protected function checkMysqlDatabaseUtf8Status(Connection $connection)
 {
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder = $connection->createQueryBuilder();
     $defaultDatabaseCharset = (string) $queryBuilder->select('DEFAULT_CHARACTER_SET_NAME')->from('information_schema.SCHEMATA')->where($queryBuilder->expr()->eq('SCHEMA_NAME', $queryBuilder->createNamedParameter($connection->getDatabase(), \PDO::PARAM_STR)))->setMaxResults(1)->execute()->fetchColumn();
     // also allow utf8mb4
     if (strpos($defaultDatabaseCharset, 'utf8') !== 0) {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL database character set check failed');
         $status->setMessage('Checking database character set failed, got key "' . $defaultDatabaseCharset . '" instead of "utf8" or "utf8mb4"');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('Your database uses utf-8. All good.');
     }
     return $status;
 }
Ejemplo n.º 10
0
 /**
  * Check register globals
  *
  * @return Status\StatusInterface
  */
 protected function checkRegisterGlobals()
 {
     $registerGlobalsEnabled = filter_var(ini_get('register_globals'), FILTER_VALIDATE_BOOLEAN, array(FILTER_REQUIRE_SCALAR, FILTER_NULL_ON_FAILURE));
     if ($registerGlobalsEnabled === true) {
         $status = new Status\ErrorStatus();
         $status->setTitle('PHP register globals on');
         $status->setMessage('register_globals=' . ini_get('register_globals') . LF . 'TYPO3 requires PHP setting "register_globals" set to off.' . ' This ancient PHP setting is a big security problem and should' . ' never be enabled:' . LF . 'register_globals=Off');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('PHP register globals off');
     }
     return $status;
 }