Skip to content

Commit

Permalink
fix: address review 2
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 24, 2024
1 parent 137986f commit 1afe55b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion console.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ function exceptionHandler($exception) {

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

$user = posix_getuid();
$userNameArray = posix_getpwuid($user);
if ($userNameArray !== false)) {
$username = null;
if ($userNameArray !== false) {
$userName = $userNameArray['name'];
}
$configUser = fileowner(OC::$configDir . 'config.php');
$configuredUser = $config->getSystemValueString('php.user', '');
if ($user !== $configUser && $userName !== $configuredUser) {
if ($user !== $configUser && $username !== null && $userName !== $configuredUser) {

Check failure

Code scanning / Psalm

TypeDoesNotContainType Error

Type null for $username is always !null

Check failure on line 140 in cron.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

cron.php:140:7: TypeDoesNotContainType: Type null for $username is always !null (see https://psalm.dev/056)
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 1afe55b

Please sign in to comment.