‪TYPO3CMS  10.4
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 
20 
26 {
34  protected ‪$recommended = [
35  'fileCreateMask' => '0660',
36  'folderCreateMask' => '2770',
37  ];
38 
42  protected ‪$names = [
43  'fileCreateMask' => 'Default File permissions',
44  'folderCreateMask' => 'Default Directory permissions',
45  ];
46 
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 = ‪FlashMessage::ERROR;
79  $extraMessage = ' (not read or writable by the user)';
80  } elseif ($perms['ow']) {
82  $permissionStatus = ‪FlashMessage::INFO;
83  $extraMessage = ' (writable by anyone on the server). This is the default behavior on a Windows system';
84  } else {
85  $permissionStatus = ‪FlashMessage::ERROR;
86  $extraMessage = ' (writable by anyone on the server)';
87  }
88  } elseif ($perms['or']) {
89  $permissionStatus = ‪FlashMessage::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 = ‪FlashMessage::OK;
93  $extraMessage = ' (group writable)';
94  $groupPermissions = true;
95  } elseif ($perms['gr']) {
96  $permissionStatus = ‪FlashMessage::OK;
97  $extraMessage = ' (group readable)';
98  $groupPermissions = true;
99  } else {
100  $permissionStatus = ‪FlashMessage::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:34
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:292
‪TYPO3\CMS\Install\FolderStructure
Definition: AbstractNode.php:16
‪TYPO3\CMS\Core\Messaging\AbstractMessage\OK
‪const OK
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Messaging\AbstractMessage\NOTICE
‪const NOTICE
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck\$names
‪array $names
Definition: DefaultPermissionsCheck.php:41
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck\getMaskStatus
‪FlashMessage getMaskStatus($which)
Definition: DefaultPermissionsCheck.php:58
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31
‪TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck
Definition: DefaultPermissionsCheck.php:26