Skip to content

SMB shares on Windows not working as external storage when using smbclient #30751

@erbth

Description

@erbth

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Install nextcloud version 23.0.0 (though older versions might be affected, too) on a fresh Debian 11 Bullseye server
  2. Install the smbclient-package to attach SMB-shares as external storage
  3. Attach external storage backed by a SMB-share on a Windows 2012R2 or Windows 2019 Server (though I believe that other versions might reproduce the behavior, too)

Expected behaviour

As a user logged into nextcloud I should be able to access the external storage-mount from the files app (potentially after entering credentials if configured so). When I click onto the share, I should enter the directory on the Windows server's share that I configured as external storage.

Actual behaviour

If I enter the credentials in the external storage's configuration, the status icon at the beginning of the row shows the red exclamation mark, which indicates that the configuration is problematic. If I configure the share s.t. users have to enter credentials, they simply won't be taken into the share but be asked to re-enter the credentials every time they click on it.

The nextcloud log however shows Icewind\SMB\Exception\Exception: Unknown error (NT_STATUS_OBJECT_NAME_INVALID) for /. (see below for full excerpt).

Description of the underlying issue

nextcloud uses icewind/smb (https://github.com/icewind1991/SMB) to communicate with SMB servers. icewind/smb is a wrapper around either libsmbclient-php or the smbclient command line tool if the former is not available. When entering a directory backed by SMB, NC performs a "stat" on the share's root-directory. For the SMB root directory the "stat" translates to a smbclient allinfo. If that smbclient allinfo fails, icewind retries with smbclient allinfo ., which is answered with STATUS_OBJECT_NAME_INVALID by W2k12r2 and W2k19. However that's only part of the issue, because undoing the changes to src/Share.php made in icewind1991/SMB@286024d is not enough. I managed to get the smbclient implementation working with these changes: erbth@a2afcac. However it's pretty slow.

By the way, I came across this issue because libsmbclient-php, which is usually packaged as php-smbclient by Debian/Ubuntu, is not part of Debian Buster (and recent Ubuntu versions, I think) due to licensing issues. That means one would have to install (and update) it manually or use the version from Debian sid. This motivated me to try the smbclient-approach (and might motivate others ;-)).

Server configuration

Operating system: Debian 11 Bullseye with up-to-date packages

Web server: Apache2

Database: MariaDB

PHP version: 7.4

Nextcloud version: (see Nextcloud admin page) 23.0.0

Updated from an older Nextcloud/ownCloud or fresh install: Updated from an older version

Where did you install Nextcloud from: Originally downloaded zip-archive from nextcloud.com and followed the admin-manual

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
  - accessibility: 1.9.0
  - activity: 2.15.0
  - calendar: 3.0.5
  - checksum: 1.1.3
  - circles: 23.0.0
  - cloud_federation_api: 1.6.0
  - comments: 1.13.0
  - contactsinteraction: 1.4.0
  - dav: 1.21.0
  - federatedfilesharing: 1.13.0
  - federation: 1.13.0
  - files: 1.18.0
  - files_external: 1.15.0
  - files_markdown: 2.3.5
  - files_pdfviewer: 2.4.0
  - files_rightclick: 1.2.0
  - files_sharing: 1.15.0
  - files_trashbin: 1.13.0
  - files_versions: 1.16.0
  - files_videoplayer: 1.12.0
  - firstrunwizard: 2.12.0
  - logreader: 2.8.0
  - lookup_server_connector: 1.11.0
  - nextcloud_announcements: 1.12.0
  - notifications: 2.11.1
  - oauth2: 1.11.0
  - onlyoffice: 7.3.0
  - password_policy: 1.13.0
  - photos: 1.5.0
  - privacy: 1.7.0
  - provisioning_api: 1.13.0
  - recommendations: 1.2.0
  - richdocuments: 5.0.1
  - serverinfo: 1.13.0
  - settings: 1.5.0
  - sharebymail: 1.13.0
  - spreed: 13.0.1
  - support: 1.6.0
  - survey_client: 1.11.0
  - systemtags: 1.13.0
  - text: 3.4.0
  - theming: 1.14.0
  - twofactor_backupcodes: 1.12.0
  - updatenotification: 1.13.0
  - viewer: 1.7.0
  - workflowengine: 2.5.0
Disabled:
  - admin_audit
  - dashboard
  - encryption
  - files_fulltextsearch
  - fulltextsearch
  - fulltextsearch_elasticsearch
  - user_ldap
  - user_status
  - weather_status

Nextcloud configuration:

Config report
I think it's not relevant... however I am of course willing to provide it if you consider it helpful.

Are you using external storage, if yes which one: smb

Are you using encryption: no

Are you using an external user-backend, if yes which one: ActiveDirectory

Client configuration

Browser: Firefox ESR 91.5.0

Operating system: Debian 11 Bullseye

Logs

Nextcloud log (data/nextcloud.log)

Nextcloud log
# Relevant parts:
{"reqId":"XfN0QelyMkiocK6BlZSU","level":2,"time":"2022-01-19T02:44:59+00:00","remoteAddr":"****","user":"****","app":"no app in context","method":"GET","url":"/nextcloud/index.php/apps/files_external/userglobalstorages/4?testOnly=false","message":"Unknown error (NT_STATUS_OBJECT_NAME_INVALID) for /","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"23.0.0.10","exception":{"Exception":"Icewind\\SMB\\Exception\\Exception","Message":"Unknown error (NT_STATUS_OBJECT_NAME_INVALID) for /","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php","line":49,"function":"unknown","class":"Icewind\\SMB\\Exception\\Exception","type":"::"},{"file":"/var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php","line":92,"function":"fromMap","class":"Icewind\\SMB\\Exception\\Exception","type":"::"},{"file":"/var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php","line":471,"function":"checkForError","class":"Icewind\\SMB\\Wrapped\\Parser","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php","line":215,"function":"parseOutput","class":"Icewind\\SMB\\Wrapped\\Share","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php","line":189,"function":"stat","class":"Icewind\\SMB\\Wrapped\\Share","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php","line":342,"function":"getFileInfo","class":"OCA\\Files_External\\Lib\\Storage\\SMB","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Common.php","line":458,"function":"stat","class":"OCA\\Files_External\\Lib\\Storage\\SMB","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php","line":717,"function":"test","class":"OC\\Files\\Storage\\Common","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/MountConfig.php","line":130,"function":"test","class":"OCA\\Files_External\\Lib\\Storage\\SMB","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":270,"function":"getBackendStatus","class":"OCA\\Files_External\\MountConfig","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/files_external/lib/Controller/UserGlobalStoragesController.php","line":123,"function":"updateStorageStatus","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"show","class":"OCA\\Files_External\\Controller\\UserGlobalStoragesController","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php","Line":31,"CustomMessage":"--"},"id":"****"}
{"reqId":"XfN0QelyMkiocK6BlZSU","level":2,"time":"2022-01-19T02:44:59+00:00","remoteAddr":"****","user":"****","app":"no app in context","method":"GET","url":"/nextcloud/index.php/apps/files_external/userglobalstorages/4?testOnly=false","message":"External storage not available: Unknown error (NT_STATUS_OBJECT_NAME_INVALID) for /","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"23.0.0.10","id":"****"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions