Edit report at https://bugs.php.net/bug.php?id=78112&edit=1
ID: 78112
Updated by: sjon@php.net
Reported by: daniele dot aluigi at semplify dot net
Summary: tempnam() wrong perms on nfsv4 fs.
-Status: Assigned
+Status: Feedback
Type: Bug
Package: Filesystem function related
Operating System: linux
PHP Version: 7.2.19
Assigned To: sjon
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2019-06-17 07:45:49] 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-14 11:46:05] 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-05 16:43:12] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78112&edit=1