Skip to content
Snippets Groups Projects
Commit 89008c7a authored by Ted Bowman's avatar Ted Bowman Committed by Ted Bowman
Browse files

add cli check

parent a588bfb0
No related branches found
No related tags found
1 merge request!1040Issue #3432476 add ConsoleUserValidator
This commit is part of merge request !1040. Comments created here will be created in the context of that merge request.
......@@ -10,6 +10,10 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Validates that the `auto-update` script is not run as the root user.
*
* We add this warning to the StatusCheckEvent and PreCreateEvent events
* instead of directly in the `auto-update` script to ensure that the warning
* is surfaced to the status report page along with other warnings and errors.
*
* @todo Remove this validator in favor of exiting the `auto-update` script as
* early as possible if run as root in https://www.drupal.org/i/3432496.
*/
......@@ -32,7 +36,7 @@ class ConsoleUserValidator implements EventSubscriberInterface {
* The stage event.
*/
public function validateConsoleUser(StatusCheckEvent|PreCreateEvent $event) {
if ($event->stage instanceof ConsoleUpdateStage && function_exists('posix_getuid') && posix_getuid() === 0) {
if (PHP_SAPI === 'cli' && $event->stage instanceof ConsoleUpdateStage && function_exists('posix_getuid') && posix_getuid() === 0) {
$event->addWarning([t('The `auto-update` script should not be run as the root user. Please run it as a less privileged user. In 3.1.0 if this script is run as the root user updates will not be preformed.')]);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment