php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: daniele dot aluigi at semplify dot net
New email:
PHP Version: OS:

 

 [2019-06-05 16:43 UTC] daniele dot aluigi at semplify dot net
Description:
------------
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.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-14 11:46 UTC] sjon@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: sjon
 [2019-06-14 11:46 UTC] sjon@php.net
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
Thanks,
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');
chmod($tmp,0600);
echo substr(sprintf('%o', fileperms($tmp)), -4);
is working fine, like all other filesystem functions, like: fopen.
In this case nfs4_getfacl returns:
A::OWNER@:rwatTnNcCy
A:g:GROUP@:tcy
A::EVERYONE@:tcy
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:
rw,noatime,hard,intr,nfsvers=4
 [2019-06-17 10:10 UTC] sjon@php.net
-Status: Assigned +Status: Feedback
 [2019-06-17 10:10 UTC] sjon@php.net
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: https://github.com/bminor/glibc/blob/7621e38bf3c58b2d0359545f1f2898017fd89d05/sysdeps/posix/tempname.c#L245

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-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 23 11:01:27 2019 UTC