Bug #17081
closedt3lib_div::mkdir() resets setgid bit on folder creation
0%
Description
markus@kaiman:.../htdocs/fileadmin$ umask # is the same for apache
0002
markus@kaiman:.../htdocs/fileadmin$ pwd
/home/projects/projectname/htdocs/fileadmin
markus@kaiman:.../htdocs/fileadmin$ ls -lad .
drwxrwsr-x 6 developer projectname 4096 2007-03-06 14:27 .
markus@kaiman:.../htdocs/fileadmin$ grep CreateMask ../typo3conf/localconf.php
$TYPO3_CONF_VARS['BE']['fileCreateMask'] = '0664';
$TYPO3_CONF_VARS['BE']['folderCreateMask'] = '0775';
markus@kaiman:.../htdocs/fileadmin$ ls -lad new_folder # created with Typo3 BE
drwxrwxr-x 2 www-data projectname 4096 2007-03-06 14:28 new_folder
t3lib_div::mkdir() contains the line
chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes
, which unfortunately speaks for the quality of the whole project. "Has a strange behaviour sometimes". How I read this: "But I was too lazy to find out and solve the real problem, instead I put this workaround in without understanding all consequences."
According to svn this bug seems to exist since before SVN was used (i.e. it is present in the earliest revision of class.t3lib_div.php in SVN).
If there was information about which strange behaviour mkdir with mode sometimes exhibits, I could have sent a patch; without this information I can only suggest to remove the chmod() line completely and wait for that issue to come up again. Then one can understand the issue and solve it.
(issue imported from #M5139)
Updated by Martin Kutschker over 17 years ago
Why don't you use
$TYPO3_CONF_VARS['BE']['folderCreateMask'] = '2775';
or
$TYPO3_CONF_VARS['BE']['folderCreateMask'] = '775';
The first one explicitely sets set-gid, the other doesn't touch it at all.
Updated by Christian Kuhn over 15 years ago
Resolved, no change required:
- No feedback for nearly two years
- Not really a bug as behavior reflects unix conventions (Quote man chmod on GNU/Linux: "The first digit selects the set user ID (4) and set group ID (2) and sticky (1) attributes.". So even php works correct here by resetting the gid field if 0 is given as first digit.
- Solution given by Martin: Use none or explicit gid settings.
Maybe the code comment could still be improved. This should be done in a new cleanup issue.