[QA] occ produces misleading 'Invalid Database' error when run as root
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 8.8k
- Forks
- 2.1k
- Avg merge
- 20h 7m
- Merged PRs (30d)
- 41
Description
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?)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the occ entry point and the database initialization path shown at lib/private/Server.php:533. Reproduce the command as root in /var/www/owncloud, compare it with the www-data invocation from /usr/bin/occ, and trace why the database error is selected. Done means root invocation is refused with a clear error instead of reporting an invalid database type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100