|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42049 tempnam() creates a file with incorrect default permissions on Windows.
Submitted: 2007-07-19 14:43 UTC Modified: 2007-07-27 01:00 UTC
From: mahesh dot vemula at in dot ibm dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5CVS-2007-07-19 (snap) OS: Windows XP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-07-19 14:43 UTC] mahesh dot vemula at in dot ibm dot com
The unique file created by tempnam() has the default permissions of 0666 on Windows. But according to documentation, the default permissions are 0600. On Linux tempnam() creates a file with permissions of 0600 as expected i.e according to documentation.

If this is the expected behavior on Windows, please fix the documentation.

Reproduce code:
$file_name = tempnam(".", "temp");
printf("%o", fileperms($file_name) );

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-19 16:07 UTC]
I think it's how chmod on windows works. Try this:

$file_name = tempnam(".", "temp");
chmod($file_name, 0600);
printf("%o", fileperms($file_name) );

I bet you still get 0666..
 [2007-07-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Feb 26 19:01:24 2021 UTC