Bug #64508

Class cache corruption in chroot environment

Added by Martin Helmich over 4 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Caching
Target version:
-
Start date:
2015-01-26
Due date:
% Done:

100%

TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
no-brainer
Is Regression:
No
Sprint Focus:

Description

Summary

This issue occurs in the rare edge case when the TYPO3 cli dispatcher is called in a chroot environment and the site is delivered via a non-chrooted web server.

In this case, all classes in the class cache will be stored with PATH_typo3 as base path, except the TYPO3\Flow classes in the core extension. These are based on the __DIR__ constant, which according to [1] resolves symlinks that generates directory paths that are invalid outside of the chroot environment.

Example

Consider the following chroot environment directory layout:

<root>
\_ html
|   \_ typo3
|       \_ index.php
|       \_ ...
\_ home
    \_ www
        \_ /p123456 -> ../../

Note the backwards-recursive symlink that is required for processes inside the chroot (like a PHP process called from the CLI) to be able to resolve non-chrooted paths.

Now consider that the CLI dispatcher is called with the absolute path:

$ php /home/www/p123456/html/typo3/typo3/cli_dispatch.phpsh ...

TYPO3 will now build the PATH_site constant from the path of the called file, i.e. /home/www/p123456/html/typo3. This is a valid path both within the chroot environment (thanks to the backward symlink) and system-wide. This path is also used in the cache_classes cache that might be built during the CLI call.

This, however, is not the case for the TYPO3 Flow classes that are included in the core extension. In the core extension's ext_autoload.php, the magic __DIR__ constant is used as base path for all TYPO3 Flow class files. Since these paths are absolute, they are used in the cache_classes cache.

However, the __DIR__ constant resolves symlinks, and in the chroot environment will resolve to /html/typo3/... instead of /home/www/p123456/html/typo3/.... This results in invalid cache entries when the cache_classes cache is accessed in a non-chrooted context.

Suggested solution

Use PATH_typo3 as base path for the TYPO3 Flow classes. Change request in Gerrit will follow shortly.

[1] http://php.net/manual/en/language.constants.predefined.php

Associated revisions

Revision 4eddbcbd (diff)
Added by Martin Helmich over 4 years ago

[BUGFIX] Fix class cache corruption in chroot environment

This commit fixes an issue that occurs in the rare edge case when the
TYPO3 cli dispatcher is called in a chroot environment and the site
is delivered via a non-chrooted web server.

In this case, all classes in the class cache will be stored with
`PATH_typo3` as base path, except the `TYPO3\Flow` classes in the
"core" extension. These are based on the DIR constant, which
according to [1] resolves symlinks that generate directory paths that
are invalid outside of the chroot environment.

[1] http://php.net/manual/en/language.constants.predefined.php

Change-Id: I34a15c7a9913afc11cdd1d179a14331b157cbd29
Releases: 6.2
Fixes: #64508
Reviewed-on: http://review.typo3.org/36301
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

History

#1 Updated by Gerrit Code Review over 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/36272

#2 Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/36301

#3 Updated by Martin Helmich over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#4 Updated by Benni Mack 12 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF