fopen fails in safe mode
| Bug #21958 | fopen fails in safe mode | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2003-01-30 00:01 UTC | Modified: | 2003-08-07 10:36 UTC |
|
||||||||||
| From: | ct at swin dot edu dot au | Assigned: | iliaa (profile) | |||||||||||
| Status: | Closed | Package: | Filesystem function related | |||||||||||
| PHP Version: | 4.3.3-dev | OS: | Tru64 UNIX 5.1A | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[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.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-01-30 18:49 UTC] ct at swin dot edu dot au
[2003-02-19 18:57 UTC] sniper@php.net
[2003-02-19 19:03 UTC] ct at swin dot edu dot au
[2003-02-19 21:41 UTC] sniper@php.net
[2003-02-19 22:58 UTC] ct at swin dot edu dot au
[2003-02-20 00:07 UTC] ct at swin dot edu dot au
[2003-02-23 23:43 UTC] ct at swin dot edu dot au
[2003-02-26 01:06 UTC] ct at swin dot edu dot au
[2003-02-26 20:44 UTC] magnus@php.net
[2003-04-01 11:29 UTC] ohp at pyrenet dot fr
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.[2003-04-23 13:57 UTC] patrick_cossette1 at uqtr dot ca
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.[2003-05-26 09:34 UTC] ohp at pyrenet dot fr
[2003-05-27 06:29 UTC] ohp at pyrenet dot fr
[2003-05-28 10:47 UTC] ohp at pyrenet dot fr
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[2003-05-30 11:12 UTC] juha dot moisio at tietonauha dot fi
[2003-06-01 23:54 UTC] ct at swin dot edu dot au
[2003-06-04 06:24 UTC] ohp at pyrenet dot fr
[2003-06-04 18:17 UTC] ct at swin dot edu dot au
[2003-06-19 10:22 UTC] ohp at pyrenet dot fr
[2003-08-07 10:36 UTC] iliaa@php.net
[2004-05-11 03:47 UTC] henrypijames at mailcity dot com
[2004-05-28 21:27 UTC] rainy at partlycloudy dot com