php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27382 fopen() does no longer create non-existant files when issued with "w"
Submitted: 2004-02-24 13:27 UTC Modified: 2004-02-24 13:36 UTC
From: pgod@php.net Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.4 OS: Linux 2.4.25
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pgod@php.net
New email:
PHP Version: OS:

 

 [2004-02-24 13:27 UTC] pgod@php.net
Description:
------------
I just switched linux kernels from 2.4.10 to 2.4.25, and now a script like this:

<?php

$fp = fopen("./test.txt", "w");
fputs($fp, "lalala");
fclose($fp);

?>

tells me:

Warning: fopen(./test.txt): failed to open stream: Invalid argument in /var/wwwroot/test.php on line 3

Warning: fputs(): supplied argument is not a valid stream resource in /var/wwwroot/test.php on line 4

Warning: fclose(): supplied argument is not a valid stream resource in /var/wwwroot/test.php on line 5

I then switched from PHP 4.3.1 to 4.3.4, with the same result. Apache ist 1.3.27. Ran smooth since month. Apache process runs as user "wwwadmin", creating the file via commandline with "touch ./test.txt" works. Safe mode definitifely not enabled. No error messages in Apache error log or system logs.

When I create the file on the command line, the error does not occur and fopen() works as expected. When I boot with Linux kernel 2.4.10, the error does not occur.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-24 13:36 UTC] pgod@php.net
Ok, have found the reason. My Apache was configured as follows:

User wwwadmin
Group "#-1"

That causes the files fopen wants to open to be created with user "wwwadmin" and group - well, here is the point where both kernels differed. Under 2.4.25 it is "65535", but the same file under 2.4.10 has a much higher gid, like "478238223" (not exactly, but something that big, cannot check now).

Well, I changed the configuration to:

User wwwadmin
Group wwwadmin

and now it works well under both kernels.

Sorry this is not really a PHP bug, but as this 'Group "#-1"' thing is the default on many Apaches, maybe it is still helpful to some people.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 02 15:01:31 2024 UTC