apps and categories in apps page are not displayed if oc_data/appdata_XXXXXX isn't writeable by webserver
Steps to reproduce
- make sure
/appdata_XXXXX is not writeable by the webserver - load the apps page in nextcloud
Expected behaviour
An error message should be displayed
Actual behaviour
no categories other than enabled and not enabled are displayed and no apps are displayed. The logs contain the following errors:
{"reqId":"8EYr7hKkWOI/kW8RLPDP","remoteAddr":"87.154.113.179","app":"index","message":"Exception: {"Exception":"OCP\\Files\\NotFoundException","Message":"\/appdata_oc80d864d4c2\/appstore","Code":0,"Trace":"#0 \/home\/oc\/doc_root\/lib\/private\/Files\/Node\/Folder.php(122): OC\\Files\\Node\\Root->get('\/appdata_oc80d8...')\n#1 \/home\/oc\/doc_root\/lib\/private\/Files\/AppData\/AppData.php(105): OC\\Files\\Node\\Folder->get('\/')\n#2 \/home\/oc\/doc_root\/lib\/private\/App\/AppStore\/Fetcher\/Fetcher.php(76): OC\\Files\\AppData\\AppData->getFolder('\/')\n#3 \/home\/oc\/doc_root\/lib\/private\/Installer.php(359): OC\\App\\AppStore\\Fetcher\\Fetcher->get()\n#4 \/home\/oc\/doc_root\/settings\/Controller\/AppSettingsController.php(280): OC\\Installer::isUpdateAvailable('systemtags', Object(OC\\App\\AppStore\\Fetcher\\AppFetcher))\n#5 [internal function]: OC\\Settings\\Controller\\AppSettingsController->listApps('enabled')\n#6 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/Http\/Dispatcher.php(160): call_user_func_array(Array, Array)\n#7 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/Http\/Dispatcher.php(90): OC\\AppFramework\\Http\\Dispatcher->executeController(Object(OC\\Settings\\Controller\\AppSettingsController), 'listApps')\n#8 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/App.php(114): OC\\AppFramework\\Http\\Dispatcher->dispatch(Object(OC\\Settings\\Controller\\AppSettingsController), 'listApps')\n#9 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php(47): OC\\AppFramework\\App::main('OC\\\\Settings\\\\Con...', 'listApps', Object(OC\\AppFramework\\DependencyInjection\\DIContainer), Array)\n#10 [internal function]: OC\\AppFramework\\Routing\\RouteActionHandler->__invoke(Array)\n#11 \/home\/oc\/doc_root\/lib\/private\/Route\/Router.php(299): call_user_func(Object(OC\\AppFramework\\Routing\\RouteActionHandler), Array)\n#12 \/home\/oc\/doc_root\/lib\/base.php(1010): OC\\Route\\Router->match('\/settings\/apps\/...')\n#13 \/home\/oc\/doc_root\/index.php(40): OC::handleRequest()\n#14 {main}","File":"\/home\/oc\/doc_root\/lib\/private\/Files\/Node\/Root.php","Line":200}","level":3,"time":"2016-12-15T20:00:58+00:00","method":"GET","url":"/index.php/settings/apps/list?category=enabled","user":"oc_admin","version":"11.0.0.10"} {"reqId":"vb1C34EtChL0z6bpXDAP","remoteAddr":"87.154.113.179","app":"index","message":"Exception: {"Exception":"OCP\\Files\\NotFoundException","Message":"\/appdata_oc80d864d4c2\/appstore","Code":0,"Trace":"#0 \/home\/oc\/doc_root\/lib\/private\/Files\/Node\/Folder.php(122): OC\\Files\\Node\\Root->get('\/appdata_oc80d8...')\n#1 \/home\/oc\/doc_root\/lib\/private\/Files\/AppData\/AppData.php(105): OC\\Files\\Node\\Folder->get('\/')\n#2 \/home\/oc\/doc_root\/lib\/private\/App\/AppStore\/Fetcher\/Fetcher.php(76): OC\\Files\\AppData\\AppData->getFolder('\/')\n#3 \/home\/oc\/doc_root\/settings\/Controller\/AppSettingsController.php(134): OC\\App\\AppStore\\Fetcher\\Fetcher->get()\n#4 [internal function]: OC\\Settings\\Controller\\AppSettingsController->listCategories()\n#5 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/Http\/Dispatcher.php(160): call_user_func_array(Array, Array)\n#6 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/Http\/Dispatcher.php(90): OC\\AppFramework\\Http\\Dispatcher->executeController(Object(OC\\Settings\\Controller\\AppSettingsController), 'listCategories')\n#7 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/App.php(114): OC\\AppFramework\\Http\\Dispatcher->dispatch(Object(OC\\Settings\\Controller\\AppSettingsController), 'listCategories')\n#8 \/home\/oc\/doc_root\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php(47): OC\\AppFramework\\App::main('OC\\\\Settings\\\\Con...', 'listCategories', Object(OC\\AppFramework\\DependencyInjection\\DIContainer), Array)\n#9 [internal function]: OC\\AppFramework\\Routing\\RouteActionHandler->__invoke(Array)\n#10 \/home\/oc\/doc_root\/lib\/private\/Route\/Router.php(299): call_user_func(Object(OC\\AppFramework\\Routing\\RouteActionHandler), Array)\n#11 \/home\/oc\/doc_root\/lib\/base.php(1010): OC\\Route\\Router->match('\/settings\/apps\/...')\n#12 \/home\/oc\/doc_root\/index.php(40): OC::handleRequest()\n#13 {main}","File":"\/home\/oc\/doc_root\/lib\/private\/Files\/Node\/Root.php","Line":200}","level":3,"time":"2016-12-15T20:00:58+00:00","method":"GET","url":"/index.php/settings/apps/categories","user":"oc_admin","version":"11.0.0.10"}
Well yes. But why would you make it not writable. There is where we store data. If you make data/<username> not writable then <username> also can't upload data.
I know my config was broken, as I executed ooc upgrade with the wrong user. My point is that the error is not handled by Nextcloud. I just get an empty screen, there is not indication for the user that something went wrong.
occ should ideally refuse being executed as the wrong user - actually, it checks the config.php owner already.
So I suppose your config.php is owned by root and the data folder by the web server user?
not quite, it's owned by the user oc and group www-data with group writable permission and I executed it as the user oc. But since I now really read the manual upgrade docs and found out about "sudo -u www-data", I'll go ahead and change the ownership of everything to www-data.
I still think the exceptions should be handled gracefully, instead of being ignored. :)
This still fails, although now it generates an Internal Server Error immediately and then a ton of log messages (that will depend on what apps you have installed and the specific version of Nextcloud you're using)).
I don't know if it's realistic to handle this very gracefully (without a lot of work) because now there's so much stuff stored here (that wasn't probably when this was originally reported since AppData was still pretty new - see #1306).
It's not as bad as, say, someone suddenly ripping out lib/ but it's kind of like that.
I'm going to close this because this now fails hard, and really that's probably a reasonable response under the circumstances. This isn't a matter the end-user can fix. It's an admin matter that only the admin can remedy.