Bug #74357 [Asn->Ver]: lchown fails to change ownership of symlink with ZTS

From: Date: Fri, 10 Sep 2021 14:40:05 +0000
Subject: Bug #74357 [Asn->Ver]: lchown fails to change ownership of symlink with ZTS
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236524@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74357&edit=1

 ID:                 74357
 Updated by:         cmb@php.net
 Reported by:        msaladna at apisnetworks dot com
 Summary:            lchown fails to change ownership of symlink with ZTS
-Status:             Assigned
+Status:             Verified
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   CentOS 7.3
 PHP Version:        7.4.23
-Assigned To:        cmb
+Assigned To:        
 Block user comment: N
 Private report:     N

 New Comment:

I can confirm the reported behavior (PHP-7.4).  It is apparently
not related to the realpath cache, since disabling the cache in
the first place doesn't make a difference.


Previous Comments:
------------------------------------------------------------------------
[2021-09-09 16:26:25] msaladna at apisnetworks dot com

Problem still persists. Sample code amended for clarity:

<?php
   echo "TS: ", PHP_ZTS, " ", PHP_VERSION, "\n";
   echo posix_getuid(), ":", posix_geteuid(), "\n";
   is_link("foo") && unlink("foo");
   symlink("/tmp", "foo");
   lchown("foo", 99);
   clearstatcache(true);
   var_dump(lstat("foo")['uid']);
?>

This is on a CentOS 7/PHP 7.4 machine.

TS: 1 7.4.23
0:0
int(0)

And on a Rocky Linux (CentOS 8)/PHP 8 machine:

TS: 1 8.0.6
0:0
int(0)

------------------------------------------------------------------------
[2021-09-09 12:20:04] cmb@php.net

What is the output of the following script:

<?php
   echo "TS: ", PHP_ZTS, "\n";
   is_link("foo") && unlink("foo");
   symlink("/tmp", "foo");
   lchown("foo", 99);
   clearstatcache(true);
   var_dump(lstat("foo")['uid']);
?>

And please check with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>

------------------------------------------------------------------------
[2017-04-01 04:07:34] msaladna at apisnetworks dot com

Description:
------------
Compiling PHP with ZTS affects performance of lchown and lchgrp. 

PHP CLI compiled without ZTS:

./configure --disable-all

ZTS is above + '--enable-maintainer-zts'

Test script:
---------------
<?php
   echo "TS: ", PHP_ZTS, "\n";
   is_link("foo") && unlink("foo");
   symlink("/tmp", "foo");
   lchown("foo", 99);
   var_dump(lstat("foo")['uid']);
?>

Expected result:
----------------
TS: 1
int(99)

Actual result:
--------------
TS: 1
int(0)


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



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


Thread (5 messages)

« previous php.bugs (#236524) next »