Bug #68926 [Ana]: is_writable returns false but file_put_contents works

From: Date: Fri, 05 Jun 2015 17:34:21 +0000
Subject: Bug #68926 [Ana]: is_writable returns false but file_put_contents works
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193154@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68926&edit=1 ID: 68926 Updated by: ab@php.net Reported by: lukyer at gmail dot com Summary: is_writable returns false but file_put_contents works Status: Analyzed Type: Bug Package: *Directory/Filesystem functions Operating System: Windows 8 64b Prof. PHP Version: 5.6Git-2015-01-27 (Git) Assigned To: ab Block user comment: N Private report: N New Comment: @webmastersguide2000, thanks for the report. How it looks like, your issue is different from what is originally reported here. If it is on the local FS, it's most likely a misconfiguration. The unmapped unix users are unlikely to be in the game, but what were imaginable for example is the ACLs difference concerning the system account for CLI and the impersonated account used under IIS. If you still think it's the same issue, please prove it with some stable reproduce case. Maybe some rolle could play that those files are additionally shared through SMB. Please test also the latest VC11 builds like PHP 5.6, the 5.4 branch only accepts the security fixes so we won't be able to pass any corrections there, just for the case. Thanks. Previous Comments: ------------------------------------------------------------------------ [2015-06-04 21:28:02] webmastersguide2000 at yahoo dot com > This issue is related to SAMBA. The problem does occur when files are accessed locally, without SMB. (SAMBA is Linux, SMB is Windows). In our case, the storage is _also_ shared from the affected machine to other clients via SMB, but the problem occurs when the files are accessed locally, not via SMB. ------------------------------------------------------------------------ [2015-06-04 21:06:42] yohgaki@php.net This issue is related to SAMBA. Anyone who experiences this, please add your Samba configurations. There is similar issue reported for session storage on mounted (shared) file system. This may be the reason why some users have session storage issue on mounted files under windows. ------------------------------------------------------------------------ [2015-06-04 19:13:28] webmastersguide2000 at yahoo dot com I get a similar symptom going back to at least 5.4.19, but without Samba. We are running: PHP Version 5.4.19 System Windows NT DEV-LMS2 6.1 build 7601 (Windows Server 2008 R2 Enterprise Edition Service Pack 1) i586 Build Date Aug 21 2013 01:06:09 Compiler MSVC9 (Visual C++ 2008) Architecture x86 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo" In my case at least, is_writeable also returns false for directories which are writeable. ------------------------------------------------------------------------ [2015-02-12 19:00:59] ab@php.net I've spent some time on debugging this and can confirm. The reason for this behavior is here https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/ChangeNotes.html#id2578661 . You probably could check that - you use samba3 or above - the folder owner is mapped to something like "nobody", with either full or restricted access rights (use right click -> security -> advanced) You also could play with the access rights on the linux machine, just to see whether it changes something in PHP behavior. The issue here is that unmapped unix user accounts are mapped to built-in windows SIDs, which are obviously have nothing to do with windows ACLs. We could currently look whether it's possible to cover this part within PHP. In general it looks more like samba compat issue, because as you've mentioned - the native shares work well. Regards ------------------------------------------------------------------------ [2015-01-29 07:12:51] lukyer at gmail dot com Drive Z in my case is Samba mapped drive using "Map network drive" function in Windows Explorer. "tmp (\\192.168.0.15\bughunt)". Any other drives works as expected. Just network Samba drives are problematic. var_dump(is_writable('Z:\tmp')); var_dump(file_put_contents('Z:\tmp\hello.txt', 'hello')); output: bool(false) int(5) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=68926 -- Edit this bug report at https://bugs.php.net/bug.php?id=68926&edit=1

« previous php.bugs (#193154) next »