|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2018-11-17 14:25 UTC] spam2 at rhsoft dot net
  [2018-11-17 18:22 UTC] requinix@php.net
 
-Status: Open
+Status: Not a bug
  [2018-11-17 18:22 UTC] requinix@php.net
  [2018-11-17 19:03 UTC] rkaiser at gmail dot com
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 00:00:01 2025 UTC | 
Description: ------------ Note: I only have PHP 7.0.5 CLI to test, not 7.0.32 Even though chgrp($file, $user) returns true, if you immediately check the permissions via posix_getgrgid(filegroup($file)) nothing has changed. Re-running the script immediately shows the group has changed. So maybe there is a time lag or file lock involved. Seems that chown() behaves normally. Test script: --------------- - log in as root - make sure you have an "apache" user, or any other user works too - echo "stuff" > my.log - run the following <?php $logpath = "./my.log"; $owner = posix_getpwuid(fileowner($logpath)); $group = posix_getgrgid(filegroup($logpath)); if ($owner['name'] != 'apache' || $group['name'] != 'apache') { // Attempt to fix the perms if (!chown($logpath, "apache")) throw new exception("Cannot change owner of %s to apache", $logpath); if (!chgrp($logpath, "apache")) throw new exception("Cannot change group of %s to apache", $logpath); // Even though chgrp() returned true, the permissions might not have actually changed. Or else posix_getgrgid(filegroup($logpath)) is incorrect. $owner = posix_getpwuid(fileowner($logpath)); $group = posix_getgrgid(filegroup($logpath)); if ($owner['name'] != 'apache' || $group['name'] != 'apache') throw new exception(sprintf("Wrong permissions on %s - user:group is %s:%s. Try re-running.\n", $logpath, $owner['name'], $group['name'])); } Expected result: ---------------- The call to posix_getgrgid(filegroup($logpath)) would reflect the group change that was just made. Actual result: -------------- It doesn't reflect the group change that was made. Re-running the script works fine.