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