[!!!][TASK] Append hash to default log file name 33/41633/5
authorAlexander Stehlik <alexander.stehlik@gmail.com>
Thu, 23 Jul 2015 22:37:04 +0000 (00:37 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 24 Jul 2015 16:01:02 +0000 (18:01 +0200)
A hash is appended to the default log file name the FileWriter uses
when no other log file is provided in the configuration.

To make this work the logFile configuration is removed for the
writerConfiguration section.

Additionally the "deprecated" log configuration section is removed
because it is currently not used by the core.

Resolves: #52705
Releases: master
Change-Id: I1a55ea2b9eb81e1298dea22dd62ec575bd3f4dcc
Reviewed-on: http://review.typo3.org/41633
Reviewed-by: Steffen Müller <typo3@t3node.com>
Tested-by: Steffen Müller <typo3@t3node.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-52705-DefaultLogConfigurationIsChanged.rst [new file with mode: 0644]

index 8e7a4d9..39d8baa 100644 (file)
@@ -36,7 +36,7 @@ class FileWriter extends AbstractWriter {
         *
         * @var string
         */
         *
         * @var string
         */
-       protected $defaultLogFile = 'typo3temp/logs/typo3.log';
+       protected $defaultLogFileTemplate = 'typo3temp/logs/typo3_%s.log';
 
        /**
         * Log file handle storage
 
        /**
         * Log file handle storage
@@ -59,7 +59,7 @@ class FileWriter extends AbstractWriter {
                // the parent constructor reads $options and sets them
                parent::__construct($options);
                if (empty($options['logFile'])) {
                // the parent constructor reads $options and sets them
                parent::__construct($options);
                if (empty($options['logFile'])) {
-                       $this->setLogFile($this->defaultLogFile);
+                       $this->setLogFile($this->getDefaultLogFileName());
                }
        }
 
                }
        }
 
@@ -215,4 +215,15 @@ class FileWriter extends AbstractWriter {
                }
        }
 
                }
        }
 
+       /**
+        * Returns the path to the default log file.
+        *
+        * Uses the defaultLogFileTemplate and replaces the %s placeholder with a short MD5 hash
+        * based on a static string and the current encryption key.
+        *
+        * @return string
+        */
+       protected function getDefaultLogFileName() {
+               return sprintf($this->defaultLogFileTemplate, GeneralUtility::shortMD5('defaultLogFile' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']));
+       }
 }
 }
index a15668b..dfd562e 100644 (file)
@@ -853,18 +853,7 @@ return array(
        'LOG' => array(
                'writerConfiguration' => array(
                        \TYPO3\CMS\Core\Log\LogLevel::WARNING => array(
        'LOG' => array(
                'writerConfiguration' => array(
                        \TYPO3\CMS\Core\Log\LogLevel::WARNING => array(
-                               \TYPO3\CMS\Core\Log\Writer\FileWriter::class => array(
-                                       'logFile' => 'typo3temp/logs/typo3.log'
-                               )
-                       )
-               ),
-               'deprecated' => array(
-                       'writerConfiguration' => array(
-                               \TYPO3\CMS\Core\Log\LogLevel::WARNING => array(
-                                       \TYPO3\CMS\Core\Log\Writer\FileWriter::class => array(
-                                               'logFile' => 'typo3conf/deprecation.log'
-                                       )
-                               )
+                               \TYPO3\CMS\Core\Log\Writer\FileWriter::class => array()
                        )
                )
        ),
                        )
                )
        ),
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-52705-DefaultLogConfigurationIsChanged.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-52705-DefaultLogConfigurationIsChanged.rst
new file mode 100644 (file)
index 0000000..cb38694
--- /dev/null
@@ -0,0 +1,59 @@
+=======================================================
+Breaking: #52705 - Default log configuration is changed
+=======================================================
+
+Description
+===========
+
+FileWriter behavior has changed
+-------------------------------
+
+The FileWriter of the logging Framework now appends a hash to its default log file which is used when no log file
+is provided in the configuration.
+
+The new default log file might now look like this (the hash depends on the current encryption key):
+
+::
+
+       typo3temp/logs/typo3_7ac500bce5.log
+
+
+Default configuration has changed
+---------------------------------
+
+For security reasons we want the default log file of TYPO3 to contain a random hash to make guessing the file name harder.
+
+Therefore the :code:`logFile` configuration is removed for the default :php:`FileWriter` configuration.
+
+Additionally the "deprecated" :php:`FileWriter` configuration is removed because it is not used by the core.
+
+
+
+Impact
+======
+
+If the log file configuration is **not** overwritten the TYPO3 default log file will change from
+:php:`typo3temp/logs/typo3.log` to :php:`typo3temp/logs/typo3_<hash>.log`.
+
+Installations with Extensions making use of the changed / removed log configurations might break.
+
+
+Affected Installations
+======================
+
+All instances that expect the default log file to be :code:`typo3temp/logs/typo3.log` for some reason.
+
+All instances that expect the :code:`logFile` configuration to be present in the :code:`writerConfiguration` for some reason.
+
+All instances that use the "deprecated" log configuration in their Extensions.
+
+All instances that use Extensions which extend the FileWriter and access the :php:`$defaultLogFile` class property
+which is replaced by :php:`$defaultLogFileTemplate` and the :php:`getDefaultLogFileName()` method.
+
+
+Migration
+=========
+
+Adjust the log configuration according to your needs in your :code:`AdditionalConfiguration.php`.
+
+Adjust any Extension code affected by the changes if needed.