From 0a8961a0e26ea37c2821c6726bfc8957d0eaf29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taavi=20Eom=C3=A4e?= Date: Mon, 2 Jun 2025 17:37:40 +0300 Subject: [PATCH] Log a warning when opcache lock file permissions could not be changed Closes GH-18742. --- NEWS | 2 ++ ext/opcache/zend_shared_alloc.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a2ce7e7ad2d..8427273c9d9 100644 --- a/NEWS +++ b/NEWS @@ -121,6 +121,8 @@ PHP NEWS . Fixed ZTS OPcache build on Cygwin. (cmb) . Added opcache.file_cache_read_only. (Samuel Melrose) . Updated default value of opcache.jit_hot_loop. (Arnaud) + . Log a warning when opcache lock file permissions could not be changed. + (Taavi Eomäe) - Output: . Fixed calculation of aligned buffer size. (cmb) diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index 8516493dd87..37dbe59f3d5 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -115,7 +115,9 @@ void zend_shared_alloc_create_lock(char *lockfile_path) zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Unable to create opcache lock file in %s: %s (%d)", lockfile_path, strerror(errno), errno); } - fchmod(lock_file, 0666); + if (fchmod(lock_file, 0666) == -1) { + zend_accel_error(ACCEL_LOG_WARNING, "Unable to change opcache lock file permissions in %s: %s (%d)", lockfile_path, strerror(errno), errno); + } val = fcntl(lock_file, F_GETFD, 0); val |= FD_CLOEXEC;