[BUGFIX] Install tool error message if session file not writeable 25/37025/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 19 Feb 2015 16:32:21 +0000 (17:32 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 19 Feb 2015 21:11:17 +0000 (22:11 +0100)
In a rare case it may happen that the install tool created a session
file in typo3temp/InstallToolSessions and later those files can not
be written or updated due to permission problems.
The install tool then fails silently without error message.
Since write out of session data happens in __destruct() a proper
error message can not be created at this point anymore. Solution
is to "test write" the session file after opening it and throw
an exception if that fails.

Resolves: #65014
Releases: master, 6.2
Change-Id: I9478f0cfb58a047842d48350b7005e64f50f52ff
Reviewed-on: http://review.typo3.org/37025
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Frank N├Ągler <typo3@naegler.net>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/install/Classes/Service/SessionService.php

index 070fdfc..5205122 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\Service;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Install\Service\Exception;
 
 /**
  * Secure session handling for the install tool.
@@ -353,7 +354,12 @@ class SessionService implements \TYPO3\CMS\Core\SingletonInterface {
         */
        public function read($id) {
                $sessionFile = $this->getSessionFile($id);
-               return (string)(@file_get_contents($sessionFile));
+               $content = (string)(@file_get_contents($sessionFile));
+               // Do a "test write" of the session file after opening it. The real session data is written in
+               // __destruct() and we can not create a sane error message there anymore, so this test should fail
+               // before if final session file can not be written due to permission problems.
+               $this->write($id, $content);
+               return $content;
        }
 
        /**
@@ -361,11 +367,19 @@ class SessionService implements \TYPO3\CMS\Core\SingletonInterface {
         *
         * @param string $id The session id
         * @param string $sessionData The data to be stored
+        * @throws Exception
         * @return bool
         */
        public function write($id, $sessionData) {
                $sessionFile = $this->getSessionFile($id);
-               return GeneralUtility::writeFile($sessionFile, $sessionData);
+               $result = GeneralUtility::writeFile($sessionFile, $sessionData);
+               if (!$result) {
+                       throw new Exception(
+                               'Session file not writable. Please check permission on typo3temp/InstallToolSessions and its subdirectories.',
+                               1424355157
+                       );
+               }
+               return $result;
        }
 
        /**