Project

General

Profile

Actions

Bug #70106

closed

Temporary files are not deleted even though GeneralUtility::unlink_tempfile is called

Added by Matteo Bonaker almost 9 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-09-25
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
GeneralUtility, temporory, tmp, temp, typo3temp, symlink
Complexity:
Is Regression:
No
Sprint Focus:

Description

If you have the following file structure (e.g. Mittwald has this) with PATH_site being /home/www/p123456/html/typo3/ ...

DIR     /html/typo3/
DIR     /html/typo3/typo3temp/
SYMLINK /home/www/p123456/ -> ../.. ("../.." refers to the server root /)
LINKED  /home/www/p123456/html/ -> /html/
LINKED  /home/www/p123456/html/typo3/ -> /html/typo3/ (this is what PATH_site contains)
LINKED  /home/www/p123456/html/typo3/typo3temp/ -> /html/typo3/typo3temp/

... then the following code will create a temporary file but will not delete it again!

$tmpFile = GeneralUtility::tempnam('test', '.txt'); //$tmpFile == '/html/typo3/typo3temp/testABCDE.txt'
GeneralUtility::unlink_tempfile($tmpFile);

This is because GeneralUtility::tempnam uses PHP's tempnam and PHP's tempnam seems to use something like realpath internally which resolves symlinks. So you end up with a $tmpFile-path that contains no unresolved symlinks. But GeneralUtility::unlink_tempfile expects the first parameter to start with exactly PATH_site (containing unresolved symlinks).

In the end either GeneralUtility::tempnam or GeneralUtility::unlink_tempfile needs to be adjusted. I personally think it would be much better to fix GeneralUtility::tempnam, because it should not return anything that does not begin with PATH_site in my opinion. Maybe something like this inside GeneralUtility::tempnam would fix it:

if(!self::isFirstPartOfStr($uploadedTempFileName, PATH_site . 'typo3temp/')) {
  $tempFileName = PATH_site . 'typo3temp' . substr(realpath($tempFileName), strlen(realpath(PATH_site . 'typo3temp')));
}


Related issues 3 (0 open3 closed)

Has duplicate TYPO3 Core - Bug #78555: "Add media by URL" does not work on our ServersClosed2016-11-03

Actions
Has duplicate TYPO3 Core - Bug #79032: Youtube & Vimeo content elements doesn't work properly in surf deployed projectsClosed2016-12-19

Actions
Has duplicate TYPO3 Core - Bug #75395: EXT:form – attachments from fileupload missing in mail because of isAllowedAbsPathClosed2016-04-04

Actions
Actions

Also available in: Atom PDF