[BUGFIX] Folder structure honors file and folderCreateMask 71/21971/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 5 Jul 2013 19:11:49 +0000 (21:11 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Fri, 5 Jul 2013 19:28:33 +0000 (21:28 +0200)
The folder structure class construct takes care of permissions
of files and folders. The patch adds support for config values
fileCreateMask and folderCreateMask.

Resolves: #49715
Related: #49162
Releases: 6.2

Change-Id: I9f41ba7f038992ef77cf212229fca524e346431f
Reviewed-on: https://review.typo3.org/21971
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php

index 6629fef..f380c45 100644 (file)
@@ -255,8 +255,8 @@ return array(
                'userHomePath' => '',                                                   // Path to the directory where TYPO3 backend-users have their home-dirs.  Eg. '/home/typo3/users/'. A home for backend user 2 would be: '/home/typo3/users/2/'. Ending slash required!
                'groupHomePath' => '',                                                  // Path to the directory where TYPO3 backend-groups have their home-dirs. Remember that the first part of this path must be 'lockRootPath'. Eg. '/home/typo3/groups/'. A home for backend group 1 would be: '/home/typo3/groups/1/'. Ending slash required!
                'userUploadDir' => '',                                                  // Suffix to the user home dir which is what gets mounted in TYPO3. Eg. if the user dir is "../123_user/" and this value is "/upload" then "../123_user/upload" gets mounted.
-               'fileCreateMask' => '0644',                                             // File mode mask for Unix file systems (when files are uploaded/created).
-               'folderCreateMask' => '0755',                                   // As above, but for folders.
+               'fileCreateMask' => '0660',                                             // File mode mask for Unix file systems (when files are uploaded/created).
+               'folderCreateMask' => '2770',                                   // As above, but for folders.
                'createGroup' => '',                                                    // Group for newly created files and folders (Unix only). Group ownership can be changed on Unix file systems (see above). Set this if you want to change the group ownership of created files/folders to a specific group. This makes sense in all cases where the webserver is running with a different user/group as you do. Create a new group on your system and add you and the webserver user to the group. Now you can safely set the last bit in fileCreateMask/folderCreateMask to 0 (e.g. 770). Important: The user who is running your webserver needs to be a member of the group you specify here! Otherwise you might get some error messages.
                'warning_email_addr' => '',                                             // Email address that will receive notification whenever an attempt to login to the Install Tool is made and that will also receive warnings whenever more than 3 failed backend login attempts (regardless of user) are detected within an hour.
                'warning_mode' => '',                                                   // Bit 1: If set, warning_email_addr will be notified every time a backend user logs in. Bit 2: If set, warning_email_addr will be notified every time an ADMIN backend user logs in. Other bits are reserved for future options.
index 7a9375f..590efb8 100644 (file)
@@ -30,103 +30,129 @@ namespace TYPO3\CMS\Install\FolderStructure;
 class DefaultFactory {
 
        /**
-        * @var array Expected folder structure
+        * Get default structure object hierarchy
+        *
+        * @throws Exception
+        * @return RootNode
+        * @TODO: Use objectManager instead of new (will be injected)
         */
-       protected $expectedDefaultStructure = array();
+       public function getStructure() {
+               $rootNode = new RootNode($this->getDefaultStructureDefinition(), NULL);
+               if (!($rootNode instanceof RootNodeInterface)) {
+                       throw new Exception(
+                               'Root node must implement RootNodeInterface',
+                               1366139176
+                       );
+               }
+               $structureFacade = new StructureFacade($rootNode);
+               if (!($structureFacade instanceof StructureFacadeInterface)) {
+                       throw new Exception(
+                               'Structure facade must implement StructureFacadeInterface',
+                               1366535827
+                       );
+               }
+               return $structureFacade;
+       }
 
        /**
-        * Constructor
+        * Default definition of folder and file structure with dynamic
+        * permission settings
+        *
+        * @return array
         */
-       public function __construct() {
-               $this->expectedDefaultStructure = array(
+       protected function getDefaultStructureDefinition() {
+               $filePermission = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'];
+               $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'];
+
+               return array(
                        // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
                        'name' => substr(PATH_site, 0, -1),
-                       'targetPermission' => '2770',
+                       'targetPermission' => $directoryPermission,
                        'children' => array(
                                array(
                                        'name' => 'typo3temp',
                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                       'targetPermission' => '2770',
+                                       'targetPermission' => $directoryPermission,
                                        'children' => array(
                                                array(
                                                        'name' => 'index.html',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                       'targetPermission' => '0660',
+                                                       'targetPermission' => $filePermission,
                                                        'targetContent' => '',
                                                ),
                                                array(
                                                        'name' => 'compressor',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'cs',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'Cache',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'GB',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'llxml',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'locks',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'pics',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'sprites',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'temp',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                        ),
                                ),
                                array(
                                        'name' => 'typo3conf',
                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                       'targetPermission' => '2770',
+                                       'targetPermission' => $directoryPermission,
                                        'children' => array(
                                                array(
                                                        'name' => 'ext',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                                array(
                                                        'name' => 'l10n',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                ),
                                        ),
                                ),
                                array(
                                        'name' => 'uploads',
                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                       'targetPermission' => '2770',
+                                       'targetPermission' => $directoryPermission,
                                        'children' => array(
                                                array(
                                                        'name' => 'index.html',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                       'targetPermission' => '0660',
+                                                       'targetPermission' => $filePermission,
                                                        'targetContent' =>
                                                                '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' . LF .
                                                                '<HTML>' . LF .
@@ -139,12 +165,12 @@ class DefaultFactory {
                                                array(
                                                        'name' => 'media',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                        'children' => array(
                                                                array(
                                                                        'name' => 'index.html',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                       'targetPermission' => '0660',
+                                                                       'targetPermission' => $filePermission,
                                                                        'targetContent' => '',
                                                                ),
                                                        ),
@@ -152,12 +178,12 @@ class DefaultFactory {
                                                array(
                                                        'name' => 'pics',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                        'children' => array(
                                                                array(
                                                                        'name' => 'index.html',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                       'targetPermission' => '0660',
+                                                                       'targetPermission' => $filePermission,
                                                                        'targetContent' => '',
                                                                ),
                                                        ),
@@ -165,12 +191,12 @@ class DefaultFactory {
                                                array(
                                                        'name' => 'tf',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                        'children' => array(
                                                                array(
                                                                        'name' => 'index.html',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                       'targetPermission' => '0660',
+                                                                       'targetPermission' => $filePermission,
                                                                        'targetContent' => '',
                                                                ),
                                                        ),
@@ -180,17 +206,17 @@ class DefaultFactory {
                                array(
                                        'name' => 'fileadmin',
                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                       'targetPermission' => '2770',
+                                       'targetPermission' => $directoryPermission,
                                        'children' => array(
                                                array(
                                                        'name' => '_temp_',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                        'children' => array(
                                                                array(
                                                                        'name' => '.htaccess',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                       'targetPermission' => '0660',
+                                                                       'targetPermission' => $filePermission,
                                                                        'targetContent' =>
                                                                                '# This file restricts access to the fileadmin/_temp_ directory. It is' . LF .
                                                                                '# meant to protect temporary files which could contain sensible' . LF .
@@ -202,7 +228,7 @@ class DefaultFactory {
                                                                array(
                                                                        'name' => 'index.html',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                       'targetPermission' => '0660',
+                                                                       'targetPermission' => $filePermission,
                                                                        'targetContent' =>
                                                                                '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' . LF .
                                                                                '<HTML>' . LF .
@@ -217,17 +243,17 @@ class DefaultFactory {
                                                array(
                                                        'name' => 'user_upload',
                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                       'targetPermission' => '2770',
+                                                       'targetPermission' => $directoryPermission,
                                                        'children' => array(
                                                                array(
                                                                        'name' => '_temp_',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
-                                                                       'targetPermission' => '2770',
+                                                                       'targetPermission' => $directoryPermission,
                                                                        'children' => array(
                                                                                array(
                                                                                        'name' => 'index.html',
                                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                                       'targetPermission' => '0660',
+                                                                                       'targetPermission' => $filePermission,
                                                                                        'targetContent' => '',
                                                                                ),
                                                                        ),
@@ -235,7 +261,7 @@ class DefaultFactory {
                                                                array(
                                                                        'name' => 'index.html',
                                                                        'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
-                                                                       'targetPermission' => '0660',
+                                                                       'targetPermission' => $filePermission,
                                                                        'targetContent' => '',
                                                                ),
                                                        ),
@@ -246,30 +272,5 @@ class DefaultFactory {
                );
        }
 
-       /**
-        * Get default structure object hierarchy
-        *
-        * @throws Exception
-        * @return RootNode
-        * @TODO: Use objectManager instead of new (will be injected)
-        * @TODO: Handle targetPermission for files / directory if set in TYPO3_CONF_VARS
-        */
-       public function getStructure() {
-               $rootNode = new RootNode($this->expectedDefaultStructure, NULL);
-               if (!($rootNode instanceof RootNodeInterface)) {
-                       throw new Exception(
-                               'Root node must implement RootNodeInterface',
-                               1366139176
-                       );
-               }
-               $structureFacade = new StructureFacade($rootNode);
-               if (!($structureFacade instanceof StructureFacadeInterface)) {
-                       throw new Exception(
-                               'Structure facade must implement StructureFacadeInterface',
-                               1366535827
-                       );
-               }
-               return $structureFacade;
-       }
 }
 ?>
\ No newline at end of file