I Cannot login. "OCP AutoloadNotAllowedException" in "apps/files_external/lib/config.php"

Cannot login. OCP\AutoloadNotAllowedException: Autoload path not allowed: /usr/local/www/nextcloud/apps/files_external/lib/config.php

Interner Serverfehler

Der Server konnte die Anfrage nicht fertig stellen.

Sollte dies erneut auftreten, sende bitte die nachfolgenden technischen Einzelheiten an Deinen Server-Administrator.

Weitere Details können im Server-Protokoll gefunden werden.
Technische Details

    Entfernte Adresse: 84.182.80.3
    Anfragekennung: c8YFCw16p1Ew9if45OTu

Nextcloud version : 19.0.2.2
Operating system and version: FreeBSD 11.3-RELEASE (iocage jail on FreeNAS 11.3-RELEASE U4)
nginx: 1.18.0
PHP version: 7.4.9

The issue you are facing:


{"reqId":"3PZcMlP2gSAWp0nm23oU","level":3,"time":"2020-08-31T19:11:41+00:00","remoteAddr":"84.182.80.3","user":"admin","app":"index","method":"GET","url":"/index.php/csrftoken","message":{"Exception":"OCP\\AutoloadNotAllowedException","Message":"Autoload path not allowed: /usr/local/www/nextcloud/apps/files_external/lib/config.php","Code":0,"Trace":[{"file":"/usr/local/www/nextcloud/lib/autoloader.php","line":165,"function":"isValidPath","class":"OC\\Autoloader","type":"->","args":["/usr/local/www/nextcloud/apps/files_external/lib/config.php"]},{"function":"load","class":"OC\\Autoloader","type":"->","args":["OC_Mount_Config"]},{"file":"/usr/local/www/nextcloud/apps-pkg/files_external/appinfo/routes.php","line":33,"function":"spl_autoload_call","args":["OC_Mount_Config"]},{"file":"/usr/local/www/nextcloud/lib/private/Route/Router.php","line":380,"args":["/usr/local/www/nextcloud/apps-pkg/files_external/appinfo/routes.php"],"function":"include_once"},{"file":"/usr/local/www/nextcloud/lib/private/Route/Router.php","line":151,"function":"requireRouteFile","class":"OC\\Route\\Router","type":"->","args":["/usr/local/www/nextcloud/apps-pkg/files_external/appinfo/routes.php","files_external"]},{"file":"/usr/local/www/nextcloud/lib/private/Route/Router.php","line":268,"function":"loadRoutes","class":"OC\\Route\\Router","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/base.php","line":1012,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/csrftoken"]},{"file":"/usr/local/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/usr/local/www/nextcloud/lib/autoloader.php","Line":140,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0","version":"19.0.2.2"}
{"reqId":"B5sgGM2Kzmg5rfC02at4","level":1,"time":"2020-08-31T19:13:23+00:00","remoteAddr":"","user":"--","app":"cli","method":"","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for local cache","userAgent":"--","version":"19.0.2.2"}
{"reqId":"B5sgGM2Kzmg5rfC02at4","level":1,"time":"2020-08-31T19:13:24+00:00","remoteAddr":"","user":"--","app":"cli","method":"","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for distributed cache","userAgent":"--","version":"19.0.2.2"}
{"reqId":"B5sgGM2Kzmg5rfC02at4","level":3,"time":"2020-08-31T19:13:24+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":{"Exception":"OCP\\AutoloadNotAllowedException","Message":"Autoload path not allowed: /usr/local/www/nextcloud/apps/files_external/lib/config.php","Code":0,"Trace":[{"file":"/usr/local/www/nextcloud/lib/autoloader.php","line":165,"function":"isValidPath","class":"OC\\Autoloader","type":"->","args":["/usr/local/www/nextcloud/apps/files_external/lib/config.php"]},{"function":"load","class":"OC\\Autoloader","type":"->","args":["OC_Mount_Config"]},{"file":"/usr/local/www/nextcloud/apps/files_external/appinfo/app.php","line":38,"function":"spl_autoload_call","args":["OC_Mount_Config"]},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_App.php","line":266,"args":["/usr/local/www/nextcloud/apps/files_external/appinfo/app.php"],"function":"require_once"},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_App.php","line":155,"function":"requireAppFile","class":"OC_App","type":"::","args":["files_external"]},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_App.php","line":128,"function":"loadApp","class":"OC_App","type":"::","args":["files_external"]},{"file":"/usr/local/www/nextcloud/lib/private/Console/Application.php","line":127,"function":"loadApps","class":"OC_App","type":"::","args":[]},{"file":"/usr/local/www/nextcloud/console.php","line":99,"function":"loadCommands","class":"OC\\Console\\Application","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/usr/local/www/nextcloud/occ","line":11,"args":["/usr/local/www/nextcloud/console.php"],"function":"require_once"}],"File":"/usr/local/www/nextcloud/lib/autoloader.php","Line":140,"CustomMessage":"--"},"userAgent":"--","version":"19.0.2.2"}

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. I upgraded from FreeNAS 11.2-RELEASE U8 to 11.3-RELEASE U4
    The warden FreeBSD 11.0-RELEASE, migrated prior to the upgrade to an iocage jail.
  2. During upgrade the nextcloud version of 17.0.9.0 was maybe detected as a plugin(?) and therefore was upgraded to 19.0.2.2. But it didn’t work.
  3. I upgraded the nc database to 18.0.8. manually and with occ and then let FreeNAS iocage upgrade the ‘plugin’ to 19.0.2.2
  4. I used the occ cmd for integrity checks, upgrades and to solve some issues
  5. I’m still get the errors listed above.

The output of your Nextcloud log in Admin > Logging:

can't login

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

root@nextcloud:/usr/local/www/nextcloud # cat config/config.php
<?php
$CONFIG = array (
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/usr/local/www/nextcloud/apps',
      'url' => '/apps',
      'writable' => true,
    ),
    1 =>
    array (
      'path' => '/usr/local/www/nextcloud/apps-pkg',
      'url' => '/apps-pkg',
      'writable' => true,
    ),
  ),
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'instanceid' => 'ocpgd7phg0fb',
  'passwordsalt' => 'pppppppppppppppppppppppppp',
  'secret' => 'ssssssssssssssssssssssssssssssss',
  'trusted_domains' =>
  array (
    0 => '172.16.240.199',
    1 => '172.16.240.26',
    2 => 'nextcloud.floogy.myhost.eu',
    3 => 'localhost',
    4 => '172.16.240.4',
    5 => '172.16.240.3',
    6 => '172.16.240.16',
    7 => 'floogy.myhost.bz',
    8 => 'floogy.myhost.de',
  ),
  'datadirectory' => '/usr/local/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '19.0.2.2',
  'overwrite.cli.url' => 'https://172.16.240.199',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'mysql.utf8mb4' => true,
  'updater.release.channel' => 'beta',
);

The output of your Apache/nginx/system log in /var/log/____:

root@nextcloud:/usr/local/www/nextcloud # tail -n2 /var/log/nginx/{access,error}.log
==> /var/log/nginx/access.log <==
84.182.80.3 - nextcloud.floogy.myhost.eu [31/Aug/2020:21:26:41 +0200] "GET /index.php/csrftoken HTTP/2.0" 500 5601 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" "-"rt=1.258 ut=1.257 cs=-
172.16.240.37 - 172.16.240.199 [31/Aug/2020:21:28:20 +0200] "GET /csrftoken HTTP/1.1" 404 146 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" "-"rt=0.000 ut=- cs=-

==> /var/log/nginx/error.log <==
2020/08/31 21:16:19 [error] 95771#102370: *195 open() "/usr/local/etc/nginx/html/csrftoken" failed (2: No such file or directory), client: 172.16.240.37, server: _, request: "GET /csrftoken HTTP/1.1", host: "172.16.240.199"
2020/08/31 21:28:20 [error] 95771#102370: *198 open() "/usr/local/etc/nginx/html/csrftoken" failed (2: No such file or directory), client: 172.16.240.37, server: _, request: "GET /csrftoken HTTP/1.1", host: "172.16.240.199"

GET /index.php/csrftoken HTTP/2.0" 500
[error] 95771#102370: *198 open() “/usr/local/etc/nginx/html/csrftoken”

EDIT:
I’m able to login, after disabling files_external!

root@nextcloud:/usr/local/www/nextcloud # sudo -u www php occ app:disable files_external

The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
files_external disabled

My Files are disappeared, and if I enable “files_external” with occ or occ web, then the error appears again.

I think, I may mounted a location where my files resides.

With locate I found this place:

root@nextcloud:/usr/local/www/nextcloud # du -sh /usr/local/www/nextcloud/data/floogy/files/
9.5G    /usr/local/www/nextcloud/data/floogy/files/

Ooops, okay, that’s because I’m logged in as admin …

So the most is fine now.

During upgrade I had to create or extent two tables manually.

MariaDB [nextcloud]> describe oc_flow_operations_scope;
+--------------+-------------+------+-----+---------+----------------+
| Field        | Type        | Null | Key | Default | Extra          |
+--------------+-------------+------+-----+---------+----------------+
| id           | bigint(20)  | NO   | PRI | NULL    | auto_increment |
| operation_id | int(11)     | NO   | MUL | 0       |                |
| type         | int(11)     | NO   |     | 0       |                |
| value        | varchar(64) | YES  |     |         |                |
+--------------+-------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)

MariaDB [nextcloud]> describe oc_flow_operations;
+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| id        | int(11)      | NO   | PRI | NULL    | auto_increment |
| class     | varchar(256) | NO   |     | NULL    |                |
| name      | varchar(256) | NO   |     | NULL    |                |
| checks    | longtext     | YES  |     | NULL    |                |
| operation | longtext     | YES  |     | NULL    |                |
| entity    | varchar(256) | NO   |     |         |                |
| events    | longtext     | NO   |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)

And then upgrade, check integrity and optimize db with occ.

Now there are still three issues in security & configuration

  1. [Files Integrity, I guess due to the chaotic upgrade pass] Einige Dateien haben die Integritätsprüfung nicht bestanden. Weiterführende Informationen befinden sich in unserer Dokumentation. (Liste der ungültigen Dateien… / [Erneut analysieren…]
  2. [getenv(“PATH” seems to return an empty response] PHP scheint zur Abfrage von Systemumgebungsvariablen nicht richtig eingerichtet zu sein. Der Test mit getenv(“PATH”) liefert nur eine leere Antwort zurück. Bitte die Installationsdokumentation :arrow_upper_right: auf Hinweise zur PHP-Konfiguration durchlesen sowie die PHP-Konfiguration Deines Servers überprüfen, insbesondere dann, wenn PHP-FPM eingesetzt wird.
  3. I cannot use “files_external”, because it throws the ‘Cannot login. OCP\AutoloadNotAllowedException: Autoload path not allowed: /usr/local/www/nextcloud/apps/files_external/lib/config.php’
  4. I had an error message on the header line: »Falscher privater Schlüssel für die Verschlüsselungs-App. Bitte aktualisieren Sie Ihren privaten Schlüssel in Ihren persönlichen Einstellungen um wieder Zugriff auf die verschlüsselten Dateien zu erhalten« “Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files”
  5. There is an issue with some PDF Files for the internal Viewer.
PDF.js v2.1.266 (build: 81f5835c)
Message: Unexpected server response (503) while retrieving PDF  https://nextcloud.floogy.myhost.eu/remote.php/webdav/Nextcloud%20Manual%20(2).pdf".

1: Is it safe to delete those files?? https://pastebin.pl/view/64e13cfd

2: Strange, because it returns the $PATH

root@nextcloud:/usr/local/www/nextcloud # php -r 'print getenv("PATH") . "\n";'
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin

3: Anyone?

4: Falscher privater Schlüssel für die Verschlüsselungs-App. Bitte aktualisieren Sie Ihren privaten Schlüssel in Ihren persönlichen Einstellungen um wieder Zugriff auf die verschlüsselten Dateien zu erhalten
(Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files)

root@nextcloud:/usr/local/www/nextcloud # grep '"SAMEORIGIN"' /usr/local/etc/nginx/nginx.conf
root@nextcloud:/usr/local/www/nextcloud # grep '"SAMEORIGIN"' /usr/local/etc/nginx/conf.d/nextcloud.conf
  add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
root@nextcloud:/usr/local/www/nextcloud # grep '"SAMEORIGIN"' .htaccess
    Header always set X-Frame-Options "SAMEORIGIN"

5: Seems to happen only on one particular file, maybe it’s corrupt, or to big?

regarding the bizarre behaviour of 2.: root@nextcloud:~ # php-fpm -i | egrep --color 'PATH|env' cgi.redirect_status_env => no value => no value PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin $_SERVER['PATH'] => /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin

https://docs.nextcloud.com//server/10/admin_manual/installation/source_installation.html#php-fpm-tips-label

But:

$ LANG=EN wget --no-check-certificate -O -  https://172.16.240.39/phpinfo.php | lynx -stdin --dump | egrep -i 'env|path'
--2020-09-01 15:13:24--  https://172.16.240.39/phpinfo.php
Connecting to 172.16.240.39:443... connected.
The certificate's owner does not match hostname '172.16.240.39'
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 'STDOUT'

-                                          [ <=>                                                                        ]  77.40K  --.-KB/s    in 0.003s

2020-09-01 15:13:24 (25.4 MB/s) - written to stdout [79253]

   Configuration File (php.ini) Path /usr/local/etc
   cgi.discard_path        0           0
   cgi.fix_pathinfo        1           1
   cgi.redirect_status_env no value    no value
   include_path .:/usr/local/share/pear .:/usr/local/share/pear
   realpath_cache_size 4096K 4096K
   realpath_cache_ttl 120 120
   sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
   XPath Support       enabled
   openssl.capath no value    no value
   session.cookie_path              /                           /
   session.save_path                no value                    no value
   Path to sendmail        /usr/sbin/sendmail -t -i
   opcache.lockfile_path                 /tmp        /tmp
   opcache.revalidate_path               Off         Off
Environment
   $_SERVER['LD_LIBRARY_PATH'] /usr/local/lib:/usr/local/lib
   $_SERVER['PATH'] /sbin:/bin:/usr/sbin:/usr/bin

I’m missing the line PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin