nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.38k stars 4.07k forks source link

[Bug]: 'OCP\Files\NotPermittedException' and 403 Error - Unable to Write Files or Folders to External Storage #43200

Closed luxmargos closed 1 month ago

luxmargos commented 9 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

I encountered an issue after upgrading to Nextcloud 28.0.1, which persisted even after updating to 28.0.2.RC5.

The internal storage owned by the user works well, with no problems in syncing.

However, when I try to create a file or folder in External Storage, I receive an error message. In the web browser, it shows a 403 error with the message 'Unable to create new file from template'. On the desktop, the NextCloud sync also fails; downloading is possible, but writing is not.

I checked the NextCloud log and found an error labeled 'OCP\Files\NotPermittedException'.

The permissions for the external storage appear to be correctly set, as shown below:

chown -R www-data:www-data MY_EXTERNAL_STORAGE chmod -R 770 MY_EXTERNAL_STORAGE

Creating a folder via the terminal works without issues:

sudo -u www-data mkdir MY_EXTERNAL_STORAGE/MyFolder

Additionally, there are no SELinux issues.

The external storage is located on the same drive as the NextCloud data folder, and there is ample disk space.

I find this problem quite peculiar.

Steps to reproduce

  1. Admin Account: Configure external storages by navigating to Admin Settings > Administration > External Storage.
  2. User Account: Sign in and access the external storage folder. Attempt to create a folder or add a 'New Text File' by clicking the '+ New' button at the top of the interface.

Expected behavior

Writing files and folders to the external storage folder without encountering any errors.

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

RHEL/CentOS

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "MY.SERVER.DOMAIN"
        ],
        "overwrite.cli.url": "https:\/\/MY.SERVER.DOMAIN",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.2.4",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "3306",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "maintenance": false,
        "filesystem_check_changes": 1,
        "tempdirectory": "\/ServerMain\/service\/nextcloud\/data_tmp\/alt",
        "loglevel": 3,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "password": "***REMOVED SENSITIVE VALUE***",
            "timeout": 1.5
        },
        "enable_previews": true,
        "preview_max_x": "2048",
        "preview_max_y": "2048",
        "jpeg_quality": "60",
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\Illustrator",
            "OC\\Preview\\Photoshop",
            "OC\\Preview\\PDF",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\SVG",
            "OC\\Preview\\Movie",
            "OC\\Preview\\MSOffice2007",
            "OC\\Preview\\MSOffice",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\TGA"
        ],
        "updater.release.channel": "beta",
        "theme": "",
        "data-fingerprint": "cf1ac45a1fc53af42dddc0ef66a4ed80",
        "twofactor_enforced": "false",
        "twofactor_enforced_groups": [
            "home"
        ],
        "twofactor_enforced_excluded_groups": [],
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "app_install_overwrite": [
            "files_rightclick",
            "imageconverter",
            "files_texteditor",
            "files_markdown"
        ],
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

{
  "reqId": "Abqt6cHe1hpu8QQ4bZHL",
  "level": 3,
  "time": "2024-01-30T07:08:59+00:00",
  "remoteAddr": "211.114.206.72",
  "user": "THE_USER",
  "app": "no app in context",
  "method": "POST",
  "url": "/ocs/v2.php/apps/files/api/v1/templates/create",
  "message": "Could not create path \"/THE_USER/files/external/EXTERNAL_STORAGE_TARGET_FOLDER/New text file.md\"",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
  "version": "28.0.2.4",
  "exception": {
    "Exception": "OCP\\Files\\NotPermittedException",
    "Message": "Could not create path \"/THE_USER/files/external/EXTERNAL_STORAGE_TARGET_FOLDER/New text file.md\"",
    "Code": 0,
    "Trace": [
      {
        "file": "/ServerMain/service/nextcloud/app/lib/private/Files/Template/TemplateManager.php",
        "line": 162,
        "function": "newFile",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->"
      },
      {
        "file": "/ServerMain/service/nextcloud/app/apps/files/lib/Controller/TemplateController.php",
        "line": 80,
        "function": "createFromTemplate",
        "class": "OC\\Files\\Template\\TemplateManager",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/ServerMain/service/nextcloud/app/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "create",
        "class": "OCA\\Files\\Controller\\TemplateController",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/ServerMain/service/nextcloud/app/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/ServerMain/service/nextcloud/app/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/ServerMain/service/nextcloud/app/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/ServerMain/service/nextcloud/app/ocs/v1.php",
        "line": 65,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/ServerMain/service/nextcloud/app/ocs/v2.php",
        "line": 23,
        "args": [
          "/ServerMain/service/nextcloud/app/ocs/v1.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/ServerMain/service/nextcloud/app/lib/private/Files/Node/Folder.php",
    "Line": 193,
    "message": "Could not create path \"/THE_USER/files/external/EXTERNAL_STORAGE_TARGET_FOLDER/New text file.md\"",
    "exception": [],
    "CustomMessage": "Could not create path \"/THE_USER/files/external/EXTERNAL_STORAGE_TARGET_FOLDER/New text file.md\""
  },
  "id": "65b8a095105cf"
}

Additional info

No response

joshtrichards commented 3 months ago
  1. Are you still experiencing this?
  2. If so, do you see any more log entries around the same time if you set your loglevel to the default (2)?
nextcloud-command commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.