Skip to content

Commit

Permalink
fix: retreive the username
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 21, 2024
1 parent ac48ed2 commit b3d21be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion console.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ function exceptionHandler($exception) {
}

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

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

Please sign in to comment.