[QA] occ produces misleading 'Invalid Database' error when run as root
Seen with 10.6.0 on ubuntu 20.04 where the apache user is www-data:
The correct way to call occ, according to e.g. the /usr/bin/occ script shipped in our docker images is
su-exec www-data php /var/www/owncloud/occ ...
If a user runs occ as root, a misleading error message occurs: (The database type is not invalid, the occ invocation is at fault)
cd /var/www/owncloud
./occ app:enable metrics
An unhandled exception has been thrown:
OC\DatabaseException: Invalid database type in /var/www/owncloud/lib/private/Server.php:533
Stack trace:
#0 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}()
#1 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet()
#2 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query()
#3 /var/www/owncloud/lib/private/Server.php(1239): OC\ServerContainer->query()
#4 /var/www/owncloud/lib/private/Server.php(412): OC\Server->getDatabaseConnection()
Expected behaviour: occ should print a proper error message, and would refuse to run when called as root user.
(Not sure if this is a regression, didn't we catch that in the past?)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed.
Im having this issue now but my command is:
root@Owncloud2022:/var/www/owncloud# sudo -u www-data php occ maintenance:mode --off An unhandled exception has been thrown: OC\DatabaseException: Invalid database type in /var/www/owncloud/lib/private/Server.php:549 Stack trace: