Thousands of log records "Failed to open dir" with LOTS of slashes, which have been inserted by Nextcloud

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 18.0.2): 19.0.3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 16.04
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.1): 7.3

The issue you are facing:
In nextcloud.log appear thousands of log records, saying that a file name is too long, while hundreds of slashes have been inserted into the file name, obviously by Nextcloud. The actual directory name in the below sample is /mnt/user/roland/Desktop/Prospects/HUK/AP6F1, which should not be too long for a modern operating system. Below AP6F1 are no more levels, only files.

root@nextcloud:/mnt/user/roland/Desktop/Prospects/HUK/AP6F1# ls
DFBEST.jcl  DFMAHNST.jcl  DFNHISTV.jcl  DSECTEX.jcl           ekoba1.orig.pl1  ENKHBA1.pl1      HCPLDSC.jcl  MA850STE.pl1  XMAHNSTA.rexx  XNHISTV.rexx
DFKEYS.jcl  DFNHISTL.jcl  DFUEBWE.jcl   d-sect_testcases.doc  EKOBA1.pl1       Erläuterung.txt  LOOKUP.cbl   XBKONTO.rexx  XNHISTL.rexx   XUEWKONT.rexx

While this is happening cron.php runs with high CPU usage (more than 3 hours).

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Established an external storage of type local and copy a directory structure from a remote location to it.

The output of your Nextcloud log in Admin > Logging:

Error	PHP	opendir(/mnt/user/roland/Desktop/Prospects/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////HUK///////////////////////AP6F1 (2)): failed to open dir: File name too long at /var/www/html/lib/private/Files/Storage/Local.php#131	

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

<?php
$CONFIG = array (
  'instanceid' => 'xx',
  'passwordsalt' => 'xx',
  'secret' => 'xx',
  'trusted_domains' => 
  array (
    0 => 'xx.xx.com',
    1 => 'xx.xx.com',
  ),
  'trusted_proxies' => 
  array (
    0 => '192.168.0.xxx',
  ),
  'forwarded_for_headers' => 
  array (
    0 => 'HTTP_X_FORWARDED',
    1 => 'HTTP_FORWARDED_FOR',
    2 => 'HTTP_X_FORWARDED_FOR',
  ),
  'datadirectory' => '/srv/nextcloud',
  'overwrite.cli.url' => 'https://xx.xx.com',
  'overwriteprotocol' => 'https',
  'default_language' => 'en',
  'dbtype' => 'mysql',
  'version' => '19.0.3.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_nextadmin',
  'dbpassword' => 'xx',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => 'xx.com',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'xx.xx.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'nextcloud',
  'mail_smtppassword' => 'xx',
  'filelocking.enabled' => 'true',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.release.channel' => 'stable',
  'auth.bruteforce.protection.enabled' => false,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'user_backends' => 
  array (
    0 => 
    array (
      'class' => 'OC_User_IMAP',
      'arguments' => 
      array (
        0 => 'xx.xx.com',
        1 => 993,
        0 => 'xx.xx.com',
        1 => 993,
        2 => 'ssl',
        3 => 'xx.xx.com',
        4 => true,
        5 => false,
      ),
    ),
  ),
  'mysql.utf8mb4' => true,
);

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

can't post this here, too much identifiable information in the error.log/access.log
Please define a specific subset.

Additionally, there appear such messages:

{"reqId":"MKizAyLyCJL4k5gKanVC","level":3,"time":"2020-09-30T12:26:40+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Trying to access array offset on value of type null at /var/www/html/lib/private/Files/Cache/Scanner.php#418","userAgent":"--","version":"19.0.3.1"}

This is related to bug #21723