|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78112 tempnam() wrong perms on nfsv4 fs.
Submitted: 2019-06-05 16:43 UTC Modified: 2019-06-30 04:22 UTC
From: daniele dot aluigi at semplify dot net Assigned: sjon (profile)
Status: No Feedback Package: Filesystem function related
PHP Version: 7.2.19 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-06-05 16:43 UTC] daniele dot aluigi at semplify dot net
Wrong behavior using tempnam() on an nfs v4 network filesystem.

Temporary file is correctly created and returned with full path, but with wrong perms: 0000 instead of 0600, so basically it's not writeable.

Works with the same mount options on the same FS but using nfs v3.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-14 11:46 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: sjon
 [2019-06-14 11:46 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

I cannot reproduce this; the following prints 0600 for me:

php -r "echo substr(sprintf('%o', fileperms(tempnam('/mnt/nfs/', 'z'))), -4);"

maybe your mount or export options are to blame?
 [2019-06-17 07:45 UTC] daniele dot aluigi at semplify dot net
-Status: Feedback +Status: Assigned
 [2019-06-17 07:45 UTC] daniele dot aluigi at semplify dot net
Output of the command: 
php -r "echo substr(sprintf('%o', fileperms(tempnam('/mnt/nfs/', 'z'))), -4);"
on our system, produce: 0000, the wrong permission.
nfs4_getfacl returns an empty resultset.

I don't think it's an NFS v4 options issue, because:
$tmp = tempnam('/nfs/vhosts/test/', 'z');
echo substr(sprintf('%o', fileperms($tmp)), -4);
is working fine, like all other filesystem functions, like: fopen.
In this case nfs4_getfacl returns:
as expected.

We also tried the same tempnam test scripts on an nfs v3 mount point, obviously with the same options, and here it works fine.

Deeply investigating, we reproduced the same issue using the "C" function used by php: mkstemp(fname)
Here again the same wrong behavior on nfs v4.

Just to be clear, these are the nfs options we used for both mount points:
 [2019-06-17 10:10 UTC]
-Status: Assigned +Status: Feedback
 [2019-06-17 10:10 UTC]
If you have the same problem with glibc then this isn't really anything we can fix in PHP. glibc simply uses fopen with O_CREATE, as can be seen here:

You could check your umask as well
 [2019-06-20 10:45 UTC] daniele dot aluigi at semplify dot net
Thanks, unfortunately is not an umask issue.
But looking for O_CREATE and nfs4 there a lot of documentation.

We deeply investigates, if you like i can update this bug, with newer info.
 [2019-06-30 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jan 22 18:01:24 2020 UTC