#37044 [Fbk->Opn]: MKDIR fails if GID differs

From: Date: Thu, 13 Apr 2006 06:22:42 +0000
Subject: #37044 [Fbk->Opn]: MKDIR fails if GID differs
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95727@lists.php.net to get a copy of this message
 ID:               37044
 User updated by:  dim at dvisionfactory dot com
 Reported By:      dim at dvisionfactory dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Directory function related
 Operating System: FreeBSD
 PHP Version:      4.4.2
 New Comment:

It is a production server! I cannot just "switch" to PHP5! Any other
suggestions?


Previous Comments:
------------------------------------------------------------------------

[2006-04-12 14:44:48] 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-12 08:26:22] tony2001@php.net

Works perfectly fine here.

------------------------------------------------------------------------

[2006-04-12 08:00:36] 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-11 18:39:42] tony2001@php.net

What if you call clearstatcache() between chgrp() and filegroup() calls
?

------------------------------------------------------------------------

[2006-04-11 18:32:00] 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




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37044&edit=1


Thread (8 messages)

« previous php.bugs (#95727) next »