From 91ac82527839cda5f05a67e7d91b579903840104 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Sat, 3 Jan 2026 14:41:57 +0100 Subject: [PATCH 1/2] Fix bug #74357: lchown fails to change ownership of symlink with ZTS --- Zend/zend_virtual_cwd.c | 2 +- ext/standard/tests/file/bug74357.phpt | 32 +++++++++++++++++++++++++++ ext/standard/tests/skipif_no_root.inc | 16 ++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/file/bug74357.phpt create mode 100644 ext/standard/tests/skipif_no_root.inc diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 366e13ce9b6ba..e4d88338bc9e7 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -1417,7 +1417,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li int ret; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) { + if (virtual_file_ex(&new_state, filename, NULL, link ? CWD_EXPAND : CWD_REALPATH)) { CWD_STATE_FREE_ERR(&new_state); return -1; } diff --git a/ext/standard/tests/file/bug74357.phpt b/ext/standard/tests/file/bug74357.phpt new file mode 100644 index 0000000000000..ebef650bb6447 --- /dev/null +++ b/ext/standard/tests/file/bug74357.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #74357 (lchown fails to change ownership of symlink with ZTS) +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +int(1000) diff --git a/ext/standard/tests/skipif_no_root.inc b/ext/standard/tests/skipif_no_root.inc new file mode 100644 index 0000000000000..ef60c14745ba6 --- /dev/null +++ b/ext/standard/tests/skipif_no_root.inc @@ -0,0 +1,16 @@ + Date: Sat, 3 Jan 2026 14:45:42 +0100 Subject: [PATCH 2/2] Update NEWS with fix for bug #74357 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index c0bc33dcae16c..3b76cc8363112 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug GH-18139 (Memory leak when overriding some settings via readline_info()). (ndossche) +- Standard: + . Fixed bug #74357 (lchown fails to change ownership of symlink with ZTS) + (Jakub Zelenka) + 15 Jan 2026, PHP 8.4.17 - Core: