Skip to content

Commit 35658d1

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: ext/standard: Retry getpwnam_r() on ERANGE in php_get_uid_by_name()
2 parents 90a65ec + d4195cb commit 35658d1

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎ext/standard/filestat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ PHPAPI zend_result php_get_uid_by_name(const char *name, uid_t *uid)
424424
try_again:
425425
err = getpwnam_r(name, &pw, pwbuf, pwbuflen, &retpwptr);
426426
if (err != 0 || retpwptr == NULL) {
427-
if (err == EAGAIN) {
427+
if (err == ERANGE) {
428428
pwbuflen *= 2;
429429
pwbuf = erealloc(pwbuf, pwbuflen);
430430
goto try_again;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
chown() and lchown() with a user name
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
6+
if (!function_exists("posix_getpwuid")) die("skip no posix_getpwuid()");
7+
if (posix_getpwuid(posix_getuid()) === false) die("skip current user has no passwd entry");
8+
?>
9+
--FILE--
10+
<?php
11+
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'chown_user_name.txt';
12+
$name = posix_getpwuid(posix_getuid())['name'];
13+
14+
var_dump(touch($filename));
15+
var_dump(chown($filename, $name));
16+
var_dump(lchown($filename, $name));
17+
?>
18+
--CLEAN--
19+
<?php
20+
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'chown_user_name.txt');
21+
?>
22+
--EXPECT--
23+
bool(true)
24+
bool(true)
25+
bool(true)

0 commit comments

Comments
 (0)