php.net |  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
Description:
------------
The unique file created by tempnam() has the default permissions of 0666 on Windows. But according to documentation http://in.php.net/manual/en/function.tempnam.php, 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:
---------------
<?php
$file_name = tempnam(".", "temp");
printf("%o", fileperms($file_name) );
unlink($file_name);
?>


Expected result:
----------------
100600

Actual result:
--------------
100666

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

<?php
$file_name = tempnam(".", "temp");
chmod($file_name, 0600);
clearstatcache();
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC