Project

General

Profile

Actions

Bug #70106

closed

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

Added by Matteo Bonaker about 9 years ago. Updated about 6 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 #1

Updated by Matteo Bonaker about 9 years ago

Simpler suggestion for the change inside GeneralUtility::tempnam:

$tempFileName = PATH_site . 'typo3temp/' . basename($tempFileName);

But keep in mind, that PHP's tempnam might fall back on the system default if it has no access rights to the temp-directory which would be a problem anyway.

Actions #2

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from New to Under Review

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50490

Actions #3

Updated by Gerrit Code Review almost 8 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50490

Actions #4

Updated by Stefan Froemken almost 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51083

Actions #6

Updated by Stefan Froemken almost 8 years ago

  • Status changed from Under Review to Resolved
Actions #7

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51086

Actions #8

Updated by Stefan Froemken almost 8 years ago

  • Status changed from Under Review to Resolved
Actions #9

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF