[SOLVED] Cannot delete folder even though permissions are correct

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, 20.0.5): 22.2.3
Operating system and version: CentOS 7
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.6
PHP version (eg, 7.4): 7.4.28

The issue you are facing:
Been having this issue for a while, and didn’t manage to find a solution. When trying to remove a folder, a message is shown saying "Error deleting file ". In the logs it states that there is a permission denied error, even though the folder in question has the right permissions: drwxr-xr-x. 2 apache apache. This is the same for renaming and moving folders to another location. Files are fine, though, for moving, renaming and deleting.

Is this the first time you’ve seen this error? N: (facing this issue for a while now)

Steps to replicate it:

  1. Delete a folder from the browser
    or
  2. Move a folder to another folder

The output of your Nextcloud log in Admin > Logging:

Error: rmdir(/media/<file_folder>/files/InstantUpload/Messages): Permission denied at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#128

    <<closure>>

    OC\Log\ErrorHandler::onError()

    /var/www/html/nextcloud/lib/private/Files/Storage/Local.php - line 128:

    rmdir()

    <<closure>>

    OC\Files\Storage\Local->rmdir()

    /var/www/html/nextcloud/apps/files_trashbin/lib/Storage.php - line 204:

    call_user_func()

    /var/www/html/nextcloud/apps/files_trashbin/lib/Storage.php - line 125:

    OCA\Files_Trashbin\Storage->doDelete()

    /var/www/html/nextcloud/apps/files_accesscontrol/lib/StorageWrapper.php - line 89:

    OCA\Files_Trashbin\Storage->rmdir()

    /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php - line 94:

    OCA\FilesAccessControl\StorageWrapper->rmdir()

    /var/www/html/nextcloud/lib/private/Files/View.php - line 1171:

    OC\Files\Storage\Wrapper\Wrapper->rmdir()

    /var/www/html/nextcloud/lib/private/Files/View.php - line 350:

    OC\Files\View->basicOperation()

    /var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php - line 309:

    OC\Files\View->rmdir()

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php - line 179:

    OCA\DAV\Connector\Sabre\Directory->delete()

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 281:

    Sabre\DAV\Tree->delete()

    /var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

    Sabre\DAV\CorePlugin->httpDelete()

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 472:

    Sabre\DAV\Server->emit()

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253:

    Sabre\DAV\Server->invokeMethod()

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 321:

    Sabre\DAV\Server->start()

    /var/www/html/nextcloud/apps/dav/lib/Server.php - line 333:

    Sabre\DAV\Server->exec()

    /var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php - line 35:

    OCA\DAV\Server->exec()

    /var/www/html/nextcloud/remote.php - line 166:

    require_once("/var/www/ht ... p")


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

<?php
$CONFIG = array (
  'instanceid' => '<REDACTED>',
  'passwordsalt' => '<REDACTED>',
  'secret' => '<REDACTED>',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '<REDACTED>',
  ),
  'datadirectory' => '<REDACTED>',
  'dbtype' => 'mysql',
  'version' => '22.2.3.0',
  'mysql.utf8mb4' => true,
  'overwrite.cli.url' => 'http://www.localhost/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '<REDACTED>',
  'dbpassword' => '<REDACTED>',
  'installed' => true,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '<REDACTED>',
  'mail_domain' => '<REDACTED>',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '<REDACTED>',
  'mail_smtppassword' => '<REDACTED>',
  'mail_smtphost' => '<REDACTED>',
  'mail_smtpport' => '<REDACTED>',
  'default_phone_region' => '<REDACTED>',
  'theme' => '',
  'loglevel' => 0,
  'enable_previews' => true,
  'updater.release.channel' => 'stable',
  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\TXT',
    1 => 'OC\\Preview\\MarkDown',
    2 => 'OC\\Preview\\OpenDocument',
    3 => 'OC\\Preview\\PDF',
    4 => 'OC\\Preview\\MSOffice2003',
    5 => 'OC\\Preview\\MSOfficeDoc',
    6 => 'OC\\Preview\\PDF',
    7 => 'OC\\Preview\\Image',
    8 => 'OC\\Preview\\Photoshop',
    9 => 'OC\\Preview\\TIFF',
    10 => 'OC\\Preview\\SVG',
    11 => 'OC\\Preview\\Font',
    12 => 'OC\\Preview\\MP3',
    13 => 'OC\\Preview\\Movie',
    14 => 'OC\\Preview\\MKV',
    15 => 'OC\\Preview\\MP4',
    16 => 'OC\\Preview\\AVI',
  ),
);

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

[Sun Apr 17 03:22:02.027244 2022] [lbmethod_heartbeat:notice] [pid 1561] AH02282: No slotmem from mod_heartmonitor
[Sun Apr 17 03:22:02.027828 2022] [ssl:warn] [pid 1561] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Apr 17 03:22:02.073454 2022] [mpm_prefork:notice] [pid 1561] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.28 configured -- resuming normal operations
[Sun Apr 17 03:22:02.073469 2022] [core:notice] [pid 1561] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Apr 17 03:25:11.594129 2022] [access_compat:error] [pid 29846] [client 163.123.142.219:51802] AH01797: client denied by server configuration: /var/www/html/nextcloud/config/getuser
[Sun Apr 17 09:26:35.849757 2022] [php7:error] [pid 20858] [client 64.225.43.102:43684] script '/var/www/html/nextcloud/wp-login.php' not found or unable to stat, referer: http://<REDACTED>/wp-login.php
[Sun Apr 17 10:31:37.965368 2022] [access_compat:error] [pid 21338] [client 212.204.146.168:51915] AH01797: client denied by server configuration: /var/www/html/nextcloud/config
[Sun Apr 17 11:14:25.821179 2022] [access_compat:error] [pid 29234] [client 86.89.227.174:49883] AH01797: client denied by server configuration: /var/www/html/nextcloud/config
[Sun Apr 17 11:26:44.624878 2022] [access_compat:error] [pid 17811] [client 86.89.227.174:49889] AH01797: client denied by server configuration: /var/www/html/nextcloud/config
[Sun Apr 17 11:47:12.651239 2022] [access_compat:error] [pid 25127] [client 86.89.227.174:49894] AH01797: client denied by server configuration: /var/www/html/nextcloud/config
[Sun Apr 17 11:59:02.015074 2022] [mpm_prefork:notice] [pid 1561] AH00171: Graceful restart requested, doing restart
[Sun Apr 17 11:59:02.074639 2022] [lbmethod_heartbeat:notice] [pid 1561] AH02282: No slotmem from mod_heartmonitor
[Sun Apr 17 11:59:02.075092 2022] [ssl:warn] [pid 1561] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Apr 17 11:59:02.106724 2022] [mpm_prefork:notice] [pid 1561] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.28 configured -- resuming normal operations
[Sun Apr 17 11:59:02.106739 2022] [core:notice] [pid 1561] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"Ylvt@lncWl@Y5ytcff0s8AAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"webdav","method":"DELETE","url":"/remote.php/dav/files/<REDACTED>/InstantUpload/Messages","message":"","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0","exception":{"Exception":"Sabre\\DAV\\Exception\\Forbidden","Message":"","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":179,"function":"delete","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":281,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/apps/dav/lib/Server.php","line":333,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/remote.php","line":166,"args":["/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","Line":311,"CustomMessage":"--"}}
{"reqId":"Ylvt@1ncWl@Y5ytcff0s8QAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"files_sharing","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0"}
{"reqId":"Ylvt@1ncWl@Y5ytcff0s8QAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"maps","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0"}
{"reqId":"Ylvt@1ncWl@Y5ytcff0s8gAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"files_sharing","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2FInstantUpload","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0"}
{"reqId":"Ylvt@1ncWl@Y5ytcff0s8gAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"maps","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2FInstantUpload","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0"}
{"reqId":"Ylvt@1ncWl@Y5ytcff0s8gAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"workflowengine","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2FInstantUpload","message":"Flow activation: rules were requested for operation Block access to a file","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0"}
{"reqId":"Ylvt@1ncWl@Y5ytcff0s8gAAAAA","level":0,"time":"2022-04-17T10:37:47+00:00","remoteAddr":"86.89.227.174","user":"<REDACTED>","app":"workflowengine","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2FInstantUpload","message":"No flow configurations is going to run Block access to a file","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","version":"22.2.3.0"}

Thanks a lot for the support :pray: !

Are you sure about the permissions? And for all the parent folders?
sudo -u apache ln -lisa /media/<file_folder>/files/InstantUpload/Messages

Thanks for the quick response! I checked the permissions and all of them have 755 permissions with apache:apache as owner, on every level from HDD mountpoint to individual folders and files…
I am not using links in my setup, nextcloud points directly to the Harddrive location (I am aware that this is going to be a pain later…).

Any other ideas what I can check? Your help is really appreciated!

It must still be a permission thing. Is it a normal folder or a groupfolder? Please upgrade your instance to the latest minor release, this is also very important for your security. It probably won’t help for your issue but you should really upgrade! :slight_smile:

Thank you @Daphne for the response! Just upgraded my system to 22.2.7, to make sure I’m all secure again :shield: ! However, as expected, this didn’t solve my problem…

The problem exists for both normal and group folders, and I checked again, and all folders (from drive mount, to the folder itself, has 755 permissions with apache:apache as owner. Really do not know, what permissions it is lacking here :open_mouth: !

Any help is appreciated @Daphne @tflidd :pray: !

CentOS, there you need to check with other security mechanisms such as SELinux as well that might block deletion. There is a page in the documentation:
https://docs.nextcloud.com/server/latest/admin_manual/installation/selinux_configuration.html

I also found a useful command to check further permissions with lsattr -a:

https://www.computerhope.com/unix/chattr.htm

3 Likes

@tflidd, thank you :medal_sports: ! It was SELinux that was blocking the rename and deletes.
As I keep my data folder outside of the /www/html/nextcloud/data folder, the policies from the docs were not sufficient. Adding an additional policy, resolved the issue:

semanage fcontext -a -t httpd_sys_rw_content_t '/media/<data_path>/nextcloud/data(/.*)?'
restorecon -Rv '/media/<data_path>/nextcloud/data'

Thanks a lot, really glad this is finally resolved!
I will also resolve my previous post, around the same topic.

1 Like