php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40267 tempnam creates file with access permissions mode of 0600
Submitted: 2007-01-29 07:27 UTC Modified: 2007-02-04 13:50 UTC
From: mpb dot mail at gmail dot com Assigned: bjori (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.4.4 OS: Linux
Private report: No CVE-ID: None
 [2007-01-29 07:27 UTC] mpb dot mail at gmail dot com
Description:
------------
The tempnam function sets the access permissions mode of the file it creates to 0600.  This behavior is undocumented and is different from the behavior of fopen, which sets the access permissions mode to 0644.

tempnam's behavior is therefore either a bug or an undocumented "feature".  If you consider this to be a "feature" and not a bug, please reclassify this bug report as a documentation request.

The revelant source files are:
  ext/standard/file.c
  main/php_open_temporary_file.c

'man mkstemp' is also interesting reading, as mkstemp behaves differently in different versions of glibc.

Thank you!


Reproduce code:
---------------
<?php

fopen ('test.txt', 'w');
tempnam ('.', 'test-');

print '<pre>';
print `ls -ln test.txt test-*`;
print '</pre>';

?>


Expected result:
----------------
-rw-r--r--  1 1424351 293975 0 Jan 28 23:08 test-ZG6Vdl
-rw-r--r--  1 1424351 293975 0 Jan 28 23:08 test.txt


Actual result:
--------------
-rw-------  1 1424351 293975 0 Jan 28 23:08 test-ZG6Vdl
-rw-r--r--  1 1424351 293975 0 Jan 28 23:08 test.txt


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-29 07:58 UTC] tony2001@php.net
Reclassified as docu problem.
 [2007-02-04 13:50 UTC] bjori@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 07:01:33 2025 UTC