From 9bfe412a396b69caa3d0ed4a8659df9789dec17a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kasper=20Sk=C3=A5rh=C3=B8j?= Date: Tue, 23 Mar 2004 13:49:31 +0000 Subject: [PATCH] * Fixed problem in Extension Manager where files and directories was not written with correct permissions. I also added t3lib_div::mkdir() general function for creating directories. git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@147 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 ++ t3lib/class.t3lib_div.php | 48 +++++++++++++++++------ t3lib/class.t3lib_extfilefunc.php | 3 +- t3lib/config_default.php | 2 +- typo3/mod/tools/em/index.php | 31 ++++++++------- typo3/sysext/cms/tslib/class.tslib_fe.php | 4 +- 6 files changed, 59 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index e31e074e75f..b73332919d8 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-03-23 Kasper Skårhøj,,, + + * Fixed problem in Extension Manager where files and directories was not written with correct permissions. I also added t3lib_div::mkdir() general function for creating directories. + 2004-03-23 Kasper Skårhøj,,, * Fixed bug that page tree didn't unfold when entering page id in the shortcut frame. diff --git a/t3lib/class.t3lib_div.php b/t3lib/class.t3lib_div.php index 6b9c7cf11e5..48aaad540f7 100755 --- a/t3lib/class.t3lib_div.php +++ b/t3lib/class.t3lib_div.php @@ -120,10 +120,10 @@ * * SECTION: FILES FUNCTIONS * 1938: function getURL($url) - * 1981: function writeFile($file,$content) + * 1981: function writeFile($file,$content) * 2004: function get_dirs($path) * 2030: function getFilesInDir($path,$extensionList='',$prependPath=0,$order='') - * 2075: function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99) + * 2075: function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99) * 2097: function removePrefixPathFromList($fileArr,$prefixToRemove) * 2114: function fixWindowsFilePath($theFile) * 2124: function resolveBackPath($pathStr) @@ -1985,13 +1985,27 @@ class t3lib_div { // Setting file system mode of file: if (@is_file($file) && TYPO3_OS!='WIN') { - @chmod ($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'])); + chmod($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'])); } return true; } } + /** + * Wrapper function for mkdir, setting folder permissions according to $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] + * + * @param string Absolute path to folder, see PHP mkdir() function. Removes trailing slash internally. + * @return boolean TRUE if @mkdir went well! + */ + function mkdir($theNewFolder) { + $theNewFolder = ereg_replace('\/$','',$theNewFolder); + if (mkdir($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']))){ + chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes + return TRUE; + } + } + /** * Returns an array with the names of folders in a specific path * Will return 'error' (string) if there were an error with reading directory content. @@ -2028,12 +2042,16 @@ class t3lib_div { * @return array Array of the files found */ function getFilesInDir($path,$extensionList='',$prependPath=0,$order='') { - $filearray=array(); - $sortarray=array(); - if ($path) { - $path = ereg_replace('/$','',$path); + + // Initialize variabels: + $filearray = array(); + $sortarray = array(); + $path = ereg_replace('\/$','',$path); + + // Find files+directories: + if (@is_dir($path)) { $extensionList = strtolower($extensionList); - $d = @dir($path); + $d = dir($path); if (is_object($d)) { while($entry=$d->read()) { if (@is_file($path.'/'.$entry)) { @@ -2047,8 +2065,10 @@ class t3lib_div { } } $d->close(); - } else return 'error'; + } else return 'error opening path: "'.$path.'"'; } + + // Sort them: if ($order) { asort($sortarray); reset($sortarray); @@ -2058,6 +2078,8 @@ class t3lib_div { } $filearray=$newArr; } + + // Return result reset($filearray); return $filearray; } @@ -2066,15 +2088,15 @@ class t3lib_div { * Recursively gather all files and folders of a path. * * @param array $fileArr: Empty input array (will have files added to it) - * @param string $path: The path to read recursively from (absolute) + * @param string $path: The path to read recursively from (absolute) (include trailing slash!) * @param string $extList: Comma list of file extensions: Only files with extensions in this list (if applicable) will be selected. * @param boolean $regDirs: If set, directories are also included in output. * @param integer $recursivityLevels: The number of levels to dig down... * @return array An array with the found files/directories. */ function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99) { - if ($regDirs) $fileArr[]=$path; - $fileArr = array_merge($fileArr,t3lib_div::getFilesInDir($path,$extList,1,1)); + if ($regDirs) $fileArr[] = $path; + $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path,$extList,1,1)); $dirs = t3lib_div::get_dirs($path); if (is_array($dirs) && $recursivityLevels>0) { @@ -2776,7 +2798,7 @@ class t3lib_div { // Setting file system mode of file: if (@is_file($destination) && TYPO3_OS!='WIN') { - @chmod ($destination, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'])); + chmod($destination, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'])); } // If here the file is copied and the temporary $source is still around, so when returning false the user can try unlink to delete the $source diff --git a/t3lib/class.t3lib_extfilefunc.php b/t3lib/class.t3lib_extfilefunc.php index 631381f5720..193cf7536d7 100755 --- a/t3lib/class.t3lib_extfilefunc.php +++ b/t3lib/class.t3lib_extfilefunc.php @@ -730,8 +730,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions { $theNewFolder = $theTarget.'/'.$theFolder; if ($this->checkPathAgainstMounts($theNewFolder)) { if (!@file_exists($theNewFolder)) { - if (@mkdir($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']))){ - @chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes + if (t3lib_div::mkdir($theNewFolder)){ $this->writelog(6,0,1,"Directory '%s' created in '%s'",Array($theFolder,$theTarget.'/')); return $theNewFolder; } else $this->writelog(6,1,100,"Directory '%s' not created. Write-permission problem in '%s'?",Array($theFolder,$theTarget.'/')); diff --git a/t3lib/config_default.php b/t3lib/config_default.php index 63fdc2e21a5..69f88f69052 100755 --- a/t3lib/config_default.php +++ b/t3lib/config_default.php @@ -98,7 +98,7 @@ $TYPO3_CONF_VARS = Array( 'userHomePath' => '', // Path to the directory where TYPO3 backend-users have their home-dirs. Eg. '/home/typo3/users/'. A home for backend user 2 would be: '/home/typo3/users/2/'. Ending slash required! 'groupHomePath' => '', // Path to the directory where TYPO3 backend-groups have their home-dirs. Remember that the first part of this path must be 'lockRootPath'. Eg. '/home/typo3/groups/'. A home for backend group 1 would be: '/home/typo3/groups/1/'. Ending slash required! 'userUploadDir' => '', // Suffix to the user home dir which is what gets mounted in TYPO3. Eg. if the user dir is "../123_user/" and this value is "/upload" then "../123_user/upload" gets mounted. - 'fileCreateMask' => '0664', // File mode mask for unix file systems (when files are uploaded/created) + 'fileCreateMask' => '0775', // File mode mask for unix file systems (when files are uploaded/created). Execute bit is set since some files installed in extensions might need that. 'folderCreateMask' => '0775', // As above, but for folders. 'warning_email_addr' => '', // Email-address that will receive a warning if there has been failed logins 4 times within an hour (all users). 'warning_mode' => '', // Bit 1: If set, warning_email_addr gets a mail everytime a user logs in. Bit 2: If set, a mail is sent if an ADMIN user logs in! Other bits reserved for future options. diff --git a/typo3/mod/tools/em/index.php b/typo3/mod/tools/em/index.php index c7dfb9a94dd..d9588a380b3 100755 --- a/typo3/mod/tools/em/index.php +++ b/typo3/mod/tools/em/index.php @@ -102,7 +102,7 @@ * * SECTION: File system operations * 2822: function createDirsInPath($dirs,$extDirPath) - * 2847: function removeExtDirectory($removePath,$removeContentOnly=0) + * 2847: function removeExtDirectory($removePath,$removeContentOnly=0) * 2908: function clearAndMakeExtensionDir($importedData,$type) * 2961: function removeCacheFiles() * 2981: function extractDirsFromFileList($files) @@ -1123,10 +1123,10 @@ EXTENSION KEYS: } elseif (md5(t3lib_div::getUrl($extDirPath.$theFile)) != $fileData['content_md5']) { $content.='Error: File "'.$extDirPath.$theFile.'" MD5 was different from the original files MD5 - so the file is corrupted!
'; } elseif (TYPO3_OS!='WIN') { - chmod ($extDirPath.$theFile, 0755); + #chmod ($extDirPath.$theFile, 0755); # SHOULD NOT do that here since writing the file should already have set adequate permissions! } } - + // No content, no errors. Create success output here: if (!$content) { $content='SUCCESS: '.$extDirPath.'
'; @@ -1153,7 +1153,7 @@ EXTENSION KEYS: $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A); $emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF); t3lib_div::writeFile($extDirPath.'ext_emconf.php',$emConfFile); - + $content.='ext_emconf.php: '.$extDirPath.'ext_emconf.php
'; $content.='Type: '.$loc.'
'; @@ -2827,7 +2827,7 @@ EXTENSION KEYS: foreach($allDirs as $dirParts) { $root.=$dirParts.'/'; if (!is_dir($extDirPath.$root)) { - @mkdir(ereg_replace('\/$','',$extDirPath.$root), 0777); + t3lib_div::mkdir($extDirPath.$root); if (!@is_dir($extDirPath.$root)) { return 'Error: The directory "'.$extDirPath.$root.'" could not be created...'; } @@ -2840,7 +2840,7 @@ EXTENSION KEYS: /** * Removes the extension directory (including content) * - * @param string Extension directory to remove. + * @param string Extension directory to remove (with trailing slash) * @param boolean If set, will leave the extension directory * @return boolean False on success, otherwise error string. */ @@ -2852,8 +2852,9 @@ EXTENSION KEYS: (t3lib_div::isFirstPartOfStr($removePath,PATH_site.$this->typePaths['S']) && $this->systemInstall) || t3lib_div::isFirstPartOfStr($removePath,PATH_site.'fileadmin/_temp_/')) // Playing-around directory... ) { - - $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$removePath,'',1); + + // All files in extension directory: + $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$removePath); if (is_array($fileArr)) { // Remove files in dirs: @@ -2866,7 +2867,7 @@ EXTENSION KEYS: $errors[] = 'Error: "'.$removeFile.'" could not be deleted!'; } } else $errors[] = 'Error: "'.$removeFile.'" was either not a file, or it was equal to the removed directory or simply outside the removed directory "'.$removePath.'"!'; - } else $errors[] = 'Error: "'.$removeFile.'" was a directory! Strange!'; + } } // Remove directories: @@ -2918,7 +2919,7 @@ EXTENSION KEYS: // Creates the typo3conf/ext/ directory if it does NOT already exist: if ((string)$type=='L' && !@is_dir($path)) { - mkdir(ereg_replace('\/$','',$path), 0777); + t3lib_div::mkdir($path); } break; default: @@ -2947,7 +2948,7 @@ EXTENSION KEYS: } // We go create... - @mkdir(ereg_replace('\/$','',$extDirPath), 0777); + t3lib_div::mkdir($extDirPath); if (!is_dir($extDirPath)) return 'ERROR: Could not create extension directory "'.$extDirPath.'"'; return array($extDirPath); } else return 'ERROR: The extension install path "'.$path.'" was not a directory.'; @@ -3253,13 +3254,13 @@ EXTENSION KEYS: $uploadArray['FILES'][$relFileName]['content_md5'] = md5($uploadArray['FILES'][$relFileName]['content']); } } - + // Return upload-array: return $uploadArray; } else return 'Error: Total size of uncompressed upload ('.$totalSize.') exceeds '.t3lib_div::formatSize($this->maxUploadSize); } } - + /** * Include a locallang file and return the $LOCAL_LANG array serialized. * @@ -3505,7 +3506,7 @@ EXTENSION KEYS: $uploadFolder = PATH_site.$this->ulFolder($extKey); if ($extInfo['EM_CONF']['uploadfolder'] && !@is_dir($uploadFolder)) { if (t3lib_div::_POST('_uploadfolder')) { // CREATE dir: - mkdir(ereg_replace('\/$','',$uploadFolder), 0777); + t3lib_div::mkdir($uploadFolder); $indexContent = ' @@ -3541,7 +3542,7 @@ EXTENSION KEYS: if (strcmp($dirP,'')) { $crDirStart.= $dirP.'/'; if (!@is_dir(PATH_site.$crDirStart)) { - mkdir(ereg_replace('\/$', '', PATH_site.$crDirStart), 0777); + t3lib_div::mkdir(PATH_site.$crDirStart); $finalDir = PATH_site.$crDirStart; } } else { diff --git a/typo3/sysext/cms/tslib/class.tslib_fe.php b/typo3/sysext/cms/tslib/class.tslib_fe.php index efdc130c7a5..e741a7fb2bc 100755 --- a/typo3/sysext/cms/tslib/class.tslib_fe.php +++ b/typo3/sysext/cms/tslib/class.tslib_fe.php @@ -117,7 +117,7 @@ * * SECTION: Various internal API functions * 2342: function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache='') - * 2389: function simulateStaticDocuments_pEnc_onlyP_proc($linkVars) + * 2389: function simulateStaticDocuments_pEnc_onlyP_proc($linkVars) * 2417: function getSimulFileName() * 2430: function encryptEmail($string,$back=0) * 2447: function checkFileInclude($incFile) @@ -1253,7 +1253,7 @@ } // if .simulateStaticDocuments was not present, the default value will rule. if (!isset($this->config['config']['simulateStaticDocuments'])) { - $this->config['config']['simulateStaticDocuments']=$this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']; + $this->config['config']['simulateStaticDocuments'] = $this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']; } // Processing for the config_array: -- 2.20.1