Jailkit User Cannot Execute Nextcloud OCC Commands

362 Views Asked by At

I have a fresh install of nextcloud 22.2.0, that I installed according to [these instructions:]1

After NC installation, I hae ZERO errors in my NC log. However, in the Overview section I have some basic wearnings that I know are "false positives" forllowing a new installation. There I want to run the NC occ in order to repair things:

./occ integrity:check-core

However, I get these errors:

Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/22/go.php?to=admin-dir_permissions

Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed
Please install one of these locales on your system and restart your webserver.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /web/lib/private/Console/Application.php:162
Stack trace:
#0 /web/console.php(98): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /web/occ(11): require_once('/web/console.ph...')
#2 {main}

I was able to resolve this error:

Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed
    Please install one of these locales on your system and restart your webserver.

By using:

chattr -i /var/www/clients/client1/web19/
jk_cp -j /var/www/clients/client1/web19/ /usr/lib/locale
chattr +i /var/www/clients/client1/web19/

Can anyone tell me how to resolve the two remaining errors so that the NC occ will work correctly?

thanks

Also the user's permissions are correct:

# ls -la /var/www/clients/client1/web19 
total 60
drwxr-xr-x 15 root  root    4096 Nov 12 15:12 .
drwxr-xr-x  9 root  root    4096 Nov 12 14:50 ..
lrwxrwxrwx  1 root  root       7 Nov 12 15:09 bin -> usr/bin
drwxr-xr-x  2 web19 client1 4096 Nov 12 14:50 cgi-bin
drwxr-xr-x  2 root  root    4096 Nov 12 17:36 dev
drwxr-xr-x  8 root  root    4096 Nov 12 15:12 etc
drwxr-xr-x  4 root  root    4096 Nov 12 15:12 home
lrwxrwxrwx  1 root  root       7 Nov 12 15:09 lib -> usr/lib
lrwxrwxrwx  1 root  root       9 Nov 12 15:09 lib64 -> usr/lib64
drwxr-xr-x  2 root  root    4096 Nov 12 19:58 log
drwx--x---  2 web19 client1 4096 Nov 12 20:05 private
drwx------  2 web19 client1 4096 Nov 12 15:09 .ssh
drwxr-xr-x  2 root  root    4096 Nov 12 14:55 ssl
drwxrwx---  2 web19 client1 4096 Nov 12 20:09 tmp
drwxr-xr-x  8 root  root    4096 Nov 12 15:09 usr
drwxr-xr-x  4 root  root    4096 Nov 12 15:12 var
drwx--x--x 14 web19 client1 4096 Nov 12 20:09 web
drwx--x---  2 web19 client1 4096 Nov 12 14:50 webdav
1

There are 1 best solutions below

0
On BEST ANSWER

I had the same problem as you and, curiously, I use the same user/client for the same service. I've resolved in the following way (in addition to yours solution about "locale").

Go into the jail root (/var/www/clients/client1/web19). Here create the directories to contain PHP stuff:

mkdir -p etc/php/7.4/cli/conf.d

Copy the system-wide php.ini for cli into jail:

cp -a /etc/php/7.4/cli/php.ini etc/php/7.4/cli/php.ini

"Hardly" link every file *.so present in system-wide conf into the jail. For example:

ln /etc/php/7.4/mods-available/apcu.ini 20-apcu.ini

If you has the cache problems too (as me), you can add a definition before run occ. I'm using the following command:

runuser -l web19 -c "cd /web; php --define apc.enable_cli=1 ./occ"

...and all seems to works fine! :-)