|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-01-20 13:06 UTC] lg at efficientip dot com
Description:
------------
chown() does not work when PHP is compiling with ZTS on FreeBSD, In fact sysconf(_SC_GETGR_R_SIZE_MAX) may return -1 if there is no hard limit on the size of the buffer needed to store all the groups returned.
Test script:
---------------
<?php
exec('touch /tmp/test')
chown('/tmp/test', 'www');
?>
Expected result:
----------------
root:/tmp # php test.php
root:/tmp # ls -l /tmp/test
-rw-r--r-- 1 www wheel 0 Jan 20 13:19 /tmp/test
Actual result:
--------------
root:/tmp # php test.php
Warning: chown(): Unable to find uid for www in /tmp/test.php on line 4
root:/tmp # ls -l /tmp/test
-rw-r--r-- 1 root wheel 0 Jan 20 13:19 /tmp/test
Patchesphp_get_uid_by_name.patch (last revision 2015-01-20 13:07 UTC by lg at efficientip dot com)Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 10:00:01 2025 UTC |
This issue is still present on PHP 7.2 with FreeBSD 11.2. The code for php_get_gid_by_name() needs the same fix as well, otherwise chgrp() gets the same result. diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index e730b5ae8d..deb0600d9f 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -303,6 +303,8 @@ PHPAPI int php_get_gid_by_name(const char *name, gid_t *gid) long grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX); char *grbuf; + if ( -1 == grbuflen ) + grbuflen = 1024; if (grbuflen < 1) { return FAILURE; } @@ -439,6 +441,8 @@ PHPAPI uid_t php_get_uid_by_name(const char *name, uid_t *uid) long pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX); char *pwbuf; + if ( -1 == pwbuflen ) + pwbuflen = 1024; if (pwbuflen < 1) { return FAILURE; }