diff --git a/console.php b/console.php index d30db9adb6ee5..0317db90fc133 100644 --- a/console.php +++ b/console.php @@ -63,15 +63,17 @@ function exceptionHandler($exception) { echo "The posix extensions are required - see https://www.php.net/manual/en/book.posix.php" . PHP_EOL; exit(1); } - $user = posix_getuid(); - $configUser = fileowner(OC::$configDir . 'config.php'); - if ($user !== $configUser) { - 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; - exit(1); + if (!\OC::$server->getConfig()->getSystemValue('config_is_read_only', false)) { + $user = posix_getuid(); + $configUser = fileowner(OC::$configDir . 'config.php'); + if ($user !== $configUser) { + 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; + exit(1); + } } $oldWorkingDir = getcwd(); diff --git a/cron.php b/cron.php index 7d661621ed090..6009bf254e445 100644 --- a/cron.php +++ b/cron.php @@ -96,13 +96,15 @@ exit(1); } - $user = posix_getuid(); - $configUser = fileowner(OC::$configDir . 'config.php'); - if ($user !== $configUser) { - 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; - exit(1); + if (!$config->getSystemValue('config_is_read_only', false)) { + $user = posix_getuid(); + $configUser = fileowner(OC::$configDir . 'config.php'); + if ($user !== $configUser) { + echo "Cron 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; + exit(1); + } }