对于NFS共享,is_writable返回false,即使它对用户www-data是可写的

I have a relative folder 'files/crm-upload', where i want to upload files. My code checks, whether is_writable() is true and only proceeds if this is the case.

The folder is mounted as a NFS share with rw and sec=sys.

I have written a test script, which i also execute on the apache to see access rights, it's result:

files/crm-upload/php_touch modification time has been changed to present time 
My effective UID is 33 but my UID is really 33
files/crm-upload/ is owned by 33 and has permissions 40777
is_readable('files/crm-upload/') gives true
is_readable('files/crm-upload/php_touch') gives true
is_writable('files/crm-upload/') gives false
is_writable('files/crm-upload/php_touch') gives true
is_writable('files/crm-upload/25/') gives true
is_writable('files/images/') gives true
file_exists('files/crm-upload/') gives true
file_exists('files/crm-upload/php_touch') gives true
Some stat uids: 

files/crm-upload/: 33
files/crm-upload/php_touch: 33
files/images/: 33

So:

  • touching a file on the share works
  • uids are correct
  • dir has correct permissions
  • is_writable for subfolders and files on the share returns true

How can this be, that only the root folder of the mounted share is not writable and everything else is?

It is a ubuntu 18.04. client, there is no SELinux running...

I don't think you have 40777. I think you have 4777 or 0777

Use 2777 or 7777

See more on https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits