From 3c0f2a2ca52b4039994a603561a34a3495d2ade7 Mon Sep 17 00:00:00 2001 From: Greg Sarjeant Date: Sun, 27 Jul 2025 15:14:34 -0400 Subject: [PATCH] Skip root test if POSIX PHP extension not installed (e.g. alpine) --- src/Framework/Prerequisites/Prerequisites.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Framework/Prerequisites/Prerequisites.php b/src/Framework/Prerequisites/Prerequisites.php index 0d63a55..c0929b4 100644 --- a/src/Framework/Prerequisites/Prerequisites.php +++ b/src/Framework/Prerequisites/Prerequisites.php @@ -528,7 +528,23 @@ class Prerequisites { // Write out guidance for storage directory permissions // if running the CLI script as root (since it will always appear to be writable) - if ($this->isCli && posix_getuid() === 0) { + if ($this->isCli && function_exists('posix_getuid') && posix_getuid() === 0) { + $this->addCheck( + 'Root User Warning', + false, + 'Running as root - permission checks may be inaccurate. After setup, ensure storage/ is owned by your web server user', + 'warning' + ); + } elseif ($this->isCli && !function_exists('posix_getuid')) { + $this->addCheck( + 'POSIX Extension', + false, + 'POSIX extension not available - cannot detect if running as root', + 'warning' + ); + } + + if ($this->isCli && function_exists('posix_getuid') && posix_getuid() === 0) { $this->log("\nšŸ“‹ ROOT USER SETUP RECOMMENDATIONS:"); $this->log("After uploading to your web server,"); $this->log("make sure the storage directory is writable by the web server user by running:");