diff --git a/config/config.sample.php b/config/config.sample.php index 751d6a5599b68..26ce0192fff5d 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -940,6 +940,15 @@ */ 'config_is_read_only' => false, +/** + * In certain environments it is desired to set the config.php owner to + * something else than the user that is running the php process. + * In that case in order to determine the user that the php process uses, + * you can overwrite the user with this config flag for console.php and cron.php + * Defaults to ``''`` (empty string) + */ +'config.owner' => '', + /** * Logging */ diff --git a/console.php b/console.php index 693a2618a8886..e76003cd0f1cc 100644 --- a/console.php +++ b/console.php @@ -43,12 +43,14 @@ function exceptionHandler($exception) { $user = posix_getuid(); $configUser = fileowner(OC::$configDir . 'config.php'); - if ($user !== $configUser) { + $configuredUser = $config->getSystemValueString('config.owner', ''); + if ($user !== $configUser && $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 'config.owner' in config.php which will overwrite this check." exit(1); } diff --git a/cron.php b/cron.php index be743664db2ba..a841c8909c8d2 100644 --- a/cron.php +++ b/cron.php @@ -131,10 +131,12 @@ $user = posix_getuid(); $configUser = fileowner(OC::$configDir . 'config.php'); + $configuredUser = $config->getSystemValueString('config.owner', ''); 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 "Another option is to configure 'config.owner' in config.php which will overwrite this check." exit(1); }