php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16367 No way to get O_EXCL
Submitted: 2002-03-31 16:09 UTC Modified: 2003-02-13 08:41 UTC
From: asd at suespammers dot org Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.2 OS: Debian GNU/Linux
Private report: No CVE-ID: None
 [2002-03-31 16:09 UTC] asd at suespammers dot org
I can't find a way to have a script create a file in a directory to be served by Apache without exposing itself to race conditions. I can't use tempnam because that doesn't give me control over the file extension. I can't use file_exits because that will race. I can't use fopen because I can't use O_EXCL|O_CREAT.

I can work around this by creating subdirectories, because mkdir fails if the directory already exists. But putting one file per directory is hardly ideal.

Having a way to use O_EXCL|O_CREAT --- that is, open a file for writing, creating it, and failing if it already exists all atomicly --- would be a big help.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-13 08:41 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

In PHP5-dev this is avaliable via the 'x' mode.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 15:00:01 2025 UTC