Skip to content

Commit

Permalink
fix(posix_getpwuid): handle false return value
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <szaimen@e.mail.de>
  • Loading branch information
szaimen committed May 22, 2024
1 parent 087ba07 commit f49d3f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions console.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ function exceptionHandler($exception) {
}

$user = posix_getuid();
$userName = posix_getpwuid($user)['name'];
$userName = posix_getpwuid($user) !== false ? posix_getpwuid($user)['name'] : '';
$configUser = fileowner(OC::$configDir . 'config.php');
$configuredUser = $config->getSystemValueString('php.user', '');
if ($user !== $configUser && $userName !== $configuredUser) {
if ($user !== $configUser && $configuredUser === '' && $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;
Expand Down
4 changes: 2 additions & 2 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
}

$user = posix_getuid();
$userName = posix_getpwuid($user)['name'];
$userName = posix_getpwuid($user) !== false ? posix_getpwuid($user)['name'] : '';
$configUser = fileowner(OC::$configDir . 'config.php');
$configuredUser = $config->getSystemValueString('php.user', '');
if ($user !== $configUser && $userName !== $configuredUser) {
if ($user !== $configUser && $configuredUser === '' && $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;
Expand Down

0 comments on commit f49d3f0

Please sign in to comment.