-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow to configure php.user #45307
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,13 +42,20 @@ function exceptionHandler($exception) { | |
} | ||
|
||
$user = posix_getuid(); | ||
$userNameArray = posix_getpwuid($user); | ||
$username = null; | ||
if ($userNameArray !== false) { | ||
$userName = $userNameArray['name']; | ||
} | ||
$configUser = fileowner(OC::$configDir . 'config.php'); | ||
if ($user !== $configUser) { | ||
$configuredUser = $config->getSystemValueString('php.user', ''); | ||
if ($user !== $configUser && $username !== null && $userName !== $configuredUser) { | ||
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; | ||
echo "Current user id: " . $user . PHP_EOL; | ||
echo "Owner id of config.php: " . $configUser . PHP_EOL; | ||
echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL; | ||
echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL; | ||
echo "Another option is to configure 'php.user' in config.php which will overwrite this check."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think as worded this is misleading, the option doesn't overwrite the check, it changes that the expected value of the check is. I would go with something like
|
||
exit(1); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,11 +130,18 @@ | |
} | ||
|
||
$user = posix_getuid(); | ||
$userNameArray = posix_getpwuid($user); | ||
$username = null; | ||
if ($userNameArray !== false) { | ||
$userName = $userNameArray['name']; | ||
} | ||
$configUser = fileowner(OC::$configDir . 'config.php'); | ||
if ($user !== $configUser) { | ||
$configuredUser = $config->getSystemValueString('php.user', ''); | ||
if ($user !== $configUser && $username !== null && $userName !== $configuredUser) { | ||
Check failure Code scanning / Psalm TypeDoesNotContainType Error
Type null for $username is always !null
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is not true? How can I fix this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure? Documentation says it should return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; | ||
echo "Current user id: " . $user . PHP_EOL; | ||
echo "Owner id of config.php: " . $configUser . PHP_EOL; | ||
echo "Another option is to configure 'php.user' in config.php which will overwrite this check."; | ||
exit(1); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check always needs to check for
$configuredUser
if set. Also accepting$configUser
can lead to the very issue this is trying to prevent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like
maybe