protected function FileOwnership::ownerIsScriptUser in Automatic Updates 8
Check if file is owned by the same user as which is running the script.
Helps identify scenarios when the check is run by web user and the files are owned by a non-web user.
Parameters
string $file_path: The file path to check.
Return value
array An array of translatable strings if there are file ownership issues.
2 calls to FileOwnership::ownerIsScriptUser()
- FileOwnership::doCheck in src/
ReadinessChecker/ FileOwnership.php - Perform checks.
- TestFileOwnership::doCheck in tests/
src/ Kernel/ ReadinessChecker/ FileOwnershipTest.php - Perform checks.
File
- src/
ReadinessChecker/ FileOwnership.php, line 30
Class
- FileOwnership
- File ownership checker.
Namespace
Drupal\automatic_updates\ReadinessCheckerCode
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;
}