TYPO3 CMS  TYPO3_8-7
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 
18 
23 {
31  protected $recommended = [
32  'fileCreateMask' => '0660',
33  'folderCreateMask' => '2770',
34  ];
35 
39  protected $names = [
40  'fileCreateMask' => 'Default File permissions',
41  'folderCreateMask' => 'Default Directory permissions',
42  ];
43 
56  public function getMaskStatus($which)
57  {
58  $octal = '0' . $GLOBALS['TYPO3_CONF_VARS']['SYS'][$which];
59  $dec = octdec($octal);
60  $perms = [
61  'ox' => (($dec & 001) == 001),
62  'ow' => (($dec & 002) == 002),
63  'or' => (($dec & 004) == 004),
64  'gx' => (($dec & 010) == 010),
65  'gw' => (($dec & 020) == 020),
66  'gr' => (($dec & 040) == 040),
67  'ux' => (($dec & 0100) == 0100),
68  'uw' => (($dec & 0200) == 0200),
69  'ur' => (($dec & 0400) == 0400),
70  'setgid' => (($dec & 02000) == 02000),
71  ];
72  $extraMessage = '';
73  $groupPermissions = false;
74  if (!$perms['uw'] || !$perms['ur']) {
75  $permissionStatus = new Status\ErrorStatus();
76  $extraMessage = ' (not read or writable by the user)';
77  } elseif ($perms['ow']) {
78  if (TYPO3_OS === 'WIN') {
79  $permissionStatus = new Status\InfoStatus();
80  $extraMessage = ' (writable by anyone on the server). This is the default behavior on a Windows system';
81  } else {
82  $permissionStatus = new Status\ErrorStatus();
83  $extraMessage = ' (writable by anyone on the server)';
84  }
85  } elseif ($perms['or']) {
86  $permissionStatus = new Status\NoticeStatus();
87  $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';
88  } elseif ($perms['gw']) {
89  $permissionStatus = new Status\OkStatus();
90  $extraMessage = ' (group writable)';
91  $groupPermissions = true;
92  } elseif ($perms['gr']) {
93  $permissionStatus = new Status\OkStatus();
94  $extraMessage = ' (group readable)';
95  $groupPermissions = true;
96  } else {
97  $permissionStatus = new Status\OkStatus();
98  }
99  $permissionStatus->setTitle($this->names[$which] . ' (SYS/' . $which . ')');
100  $message = 'Recommended: ' . $this->recommended[$which] . '.';
101  $message .= ' Currently configured as ';
102  if ($GLOBALS['TYPO3_CONF_VARS']['SYS'][$which] === $this->recommended[$which]) {
103  $message .= 'recommended';
104  } else {
105  $message .= $GLOBALS['TYPO3_CONF_VARS']['SYS'][$which];
106  }
107  $message .= $extraMessage . '.';
108  if ($groupPermissions) {
109  $message .= ' This is fine as long as the web server\'s group only comprises trusted users.';
110  if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'])) {
111  $message .= ' Your site is configured (SYS/createGroup) to write as group \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] . '\'.';
112  }
113  }
114  $permissionStatus->setMessage($message);
115  return $permissionStatus;
116  }
117 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']