‪TYPO3CMS  ‪main
DefaultPermissionsCheck.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
27 {
35  protected ‪$recommended = [
36  'fileCreateMask' => '0660',
37  'folderCreateMask' => '2770',
38  ];
39 
43  protected ‪$names = [
44  'fileCreateMask' => 'Default File permissions',
45  'folderCreateMask' => 'Default Directory permissions',
46  ];
47 
59  public function ‪getMaskStatus($which): ‪FlashMessage
60  {
61  $octal = '0' . ‪$GLOBALS['TYPO3_CONF_VARS']['SYS'][$which];
62  $dec = octdec($octal);
63  $perms = [
64  'ox' => ($dec & 001) == 001,
65  'ow' => ($dec & 002) == 002,
66  'or' => ($dec & 004) == 004,
67  'gx' => ($dec & 010) == 010,
68  'gw' => ($dec & 020) == 020,
69  'gr' => ($dec & 040) == 040,
70  'ux' => ($dec & 0100) == 0100,
71  'uw' => ($dec & 0200) == 0200,
72  'ur' => ($dec & 0400) == 0400,
73  'setgid' => ($dec & 02000) == 02000,
74  ];
75  $extraMessage = '';
76  $groupPermissions = false;
77  if (!$perms['uw'] || !$perms['ur']) {
78  $permissionStatus = ContextualFeedbackSeverity::ERROR;
79  $extraMessage = ' (not read or writable by the user)';
80  } elseif ($perms['ow']) {
82  $permissionStatus = ContextualFeedbackSeverity::INFO;
83  $extraMessage = ' (writable by anyone on the server). This is the default behavior on a Windows system';
84  } else {
85  $permissionStatus = ContextualFeedbackSeverity::ERROR;
86  $extraMessage = ' (writable by anyone on the server)';
87  }
88  } elseif ($perms['or']) {
89  $permissionStatus = ContextualFeedbackSeverity::NOTICE;
90  $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';
91  } elseif ($perms['gw']) {
92  $permissionStatus = ContextualFeedbackSeverity::OK;
93  $extraMessage = ' (group writable)';
94  $groupPermissions = true;
95  } elseif ($perms['gr']) {
96  $permissionStatus = ContextualFeedbackSeverity::OK;
97  $extraMessage = ' (group readable)';
98  $groupPermissions = true;
99  } else {
100  $permissionStatus = ContextualFeedbackSeverity::OK;
101  }
102  $message = 'Recommended: ' . $this->recommended[$which] . '.';
103  $message .= ' Currently configured as ';
104  if (‪$GLOBALS['TYPO3_CONF_VARS']['SYS'][$which] === $this->recommended[$which]) {
105  $message .= 'recommended';
106  } else {
107  $message .= ‪$GLOBALS['TYPO3_CONF_VARS']['SYS'][$which];
108  }
109  $message .= $extraMessage . '.';
110  if ($groupPermissions) {
111  $message .= ' This is fine as long as the web server\'s group only comprises trusted users.';
112  if (!empty(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'])) {
113  $message .= ' Your site is configured (SYS/createGroup) to write as group \'' . ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] . '\'.';
114  }
115  }
116  return new FlashMessage(
117  $message,
118  $this->names[$which] . ' (SYS/' . $which . ')',
119  $permissionStatus
120  );
121  }
122 }
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck\$recommended
‪$recommended
Definition: DefaultPermissionsCheck.php:35
‪TYPO3\CMS\Install\FolderStructure
Definition: AbstractNode.php:16
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck\getMaskStatus
‪getMaskStatus($which)
Definition: DefaultPermissionsCheck.php:58
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck\$names
‪array $names
Definition: DefaultPermissionsCheck.php:42
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck
Definition: DefaultPermissionsCheck.php:27
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static isWindows()
Definition: Environment.php:287