php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37044 MKDIR fails if GID differs
Submitted: 2006-04-11 18:32 UTC Modified: 2006-04-21 01:00 UTC
From: dim at dvisionfactory dot com Assigned:
Status: No Feedback Package: Directory function related
PHP Version: 4.4.2 OS: FreeBSD
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dim at dvisionfactory dot com
New email:
PHP Version: OS:

 

 [2006-04-11 18:32 UTC] dim at dvisionfactory dot com
Description:
------------
MKDIR has a strange behaviour. In my case, I tried to the following:

- Create a directory A
- Change group of A
- Create directory B which is a sub-directory of A -> ERROR

I wrote a test case. 
The strange thing: 
I create directory A by mkdir('A'); and I change it's group by chgrp('A', 'some_user');. fileowner('A'); return as expected '80' which is the user 'www', but filegroup('A') also returns '80', although it should be '1005' (='some_user'). If I now try an 'ls -l' in a shell I get "www:some_user", which indicates that chgrp('A', 'some_user'); was successfull.



Reproduce code:
---------------
function mk_dir($dir, $ch_grp = true) {
  mkdir($dir);
  if (!is_dir($dir)) {
	echo 'FAIL';
  } else {
	chmod($dir, 504);
	if ($ch_grp) chgrp($dir, 'some_user');
	echo 'SUCCESS';
	echo ', ' . fileperms($dir);
	echo ', ' . fileowner($dir);
	echo ', ' . filegroup($dir);
  }
}


mk_dir('/var/www/directory/test1');
	// OUTPUT: SUCCESS, 16877, 80, 80
mk_dir('/var/www/directory/test1/test2');
	// OUTPUT: FAIL, 16877, 80, 80
rmdir('/var/www/directory/test1/test2'); // CLEAN UP
rmdir('/var/www/directory/test1');       // CLEAN UP

mk_dir('/var/www/directory/test1', false);
	// OUTPUT: SUCCESS, 16877, 80, 80
mk_dir('/var/www/directory/test1/test2', false);
	// OUTPUT: SUCCESS, 16877, 80, 80
rmdir('/var/www/directory/test1/test2'); // CLEAN UP
rmdir('/var/www/directory/test1');       // CLEAN UP



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-11 18:39 UTC] tony2001@php.net
What if you call clearstatcache() between chgrp() and filegroup() calls ?
 [2006-04-12 08:00 UTC] dim at dvisionfactory dot com
I've added "clearstatcache()" after "chgrp(..)"!
Now "filegroup()" produces the right output, but it hasn't solved my problem.


Output of the script:

SUCCESS, 16888, 80, 80
FAIL, 16888, 80, 1005
SUCCESS, 16888, 80, 80
SUCCESS, 1688, 80, 80
 [2006-04-12 08:26 UTC] tony2001@php.net
Works perfectly fine here.
 [2006-04-12 14:44 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-04-13 06:22 UTC] dim at dvisionfactory dot com
It is a production server! I cannot just "switch" to PHP5! Any other suggestions?
 [2006-04-13 11:07 UTC] derick@php.net
You don't have to install it to try it... 
 [2006-04-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 14:01:27 2024 UTC