FileOwnership.php in Automatic Updates 8
File
src/ReadinessChecker/FileOwnership.php
View source
<?php
namespace Drupal\automatic_updates\ReadinessChecker;
class FileOwnership extends Filesystem {
protected function doCheck() {
$file_path = $this
->getRootPath() . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, [
'core',
'core.api.php',
]);
return $this
->ownerIsScriptUser($file_path);
}
protected function ownerIsScriptUser($file_path) {
$messages = [];
if (function_exists('posix_getuid')) {
$file_owner_uid = fileowner($file_path);
$script_uid = posix_getuid();
if ($file_owner_uid !== $script_uid) {
$messages[] = $this
->t('Files are owned by uid "@owner" but PHP is running as uid "@actual". The file owner and PHP user should be the same during an update.', [
'@owner' => $file_owner_uid,
'@file' => $file_path,
'@actual' => $script_uid,
]);
}
}
return $messages;
}
}