|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-30 00:01 UTC] ct at swin dot edu dot au
PHP 4.2.3 configured in safe mode cannot create new files.
$fname = "/web/ct/tmp/file.txt";
$filePtr = fopen($fname,"w");
Warning: Unable to access /web/ct/tmp/file.txt in /web/ct/test4.php on line 4
Warning: fopen("/web/ct/tmp/file.txt", "w") - No such file or directory in /web/ct/test4.php on line 4
The permissions on the directory are:
drwxrwxrwx 2 root system 8192 Jan 30 16:42 tmp
If the file /web/ct/tmp/file.txt already exists, PHP can open it for writing.
PHP 4.1.2 can successfully create files using the same configuration.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 11:00:01 2025 UTC |
I have the same problem on 4.2.3 and 4.3.1. I noticed that making touch before fopen("xxx","w") creates the file so fopen succeeds.With AIX 4.3.3 and PHP 4.3.1. With safe_mode on , I cannot create a file with neither touch nor fopen nor mkdir. (With safe_mode off, the creation works). Apache is running under user "web" and group "web". I have the directory /web/hee_dev whose owner is web.web with permissions rwxr-s--- I have the script testing.php located in that directory: <? $fp=fopen("filetocreate","w+"); ?> If the file "filetocreate" does not already exist, I get the following error while executing the script: Warning: Unable to access filetocreate in /web/hee_dev/testing.php on line 2 Warning: fopen("filetocreate", "w+") - No such file or directory in /web/hee_dev/testing.php on line 2 If the file already exists, I can open it without any problem. I had read somewhere in the bug database that this should be solved by now, but with 4.3.1, it still produces this error.after 2 strggling, I came with the following path on safe_mode.c against 4.3.2RC4. Not sure it's the right thing to do. could someone have a look? Regards *** main/safe_mode.c.orig lun mrs 17 14:50:23 2003 --- main/safe_mode.c mar mai 27 15:06:30 2003 *************** *** 66,71 **** --- 66,72 ---- mode = CHECKUID_DISALLOW_FILE_NOT_EXISTS; } else { mode = CHECKUID_CHECK_FILE_AND_DIR; + flags=1; } } *************** *** 81,86 **** --- 82,88 ---- * If that fails, passthrough and check directory... */ if (mode != CHECKUID_ALLOW_ONLY_DIR) { + strcpy(path,filename); VCWD_REALPATH(filename, path); ret = VCWD_STAT(path, &sb); if (ret < 0) { this works on Unixware 713