Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextcloud: SMB/CIFS external storages do not work with the php-smbclient extension enabled #224769

Open
pulsastrix opened this issue Apr 5, 2023 · 0 comments
Labels
0.kind: bug Something is broken

Comments

@pulsastrix
Copy link

Describe the bug

Using the php-smbclient extension for the SMB external storages backend (which is the preferred way of enabling SMB access according to the Nextcloud documentation), it is not possible to access SMB shares due to a regression in libsmbclient 4.17.5 (see nextcloud/server#36773).

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a Nix configuration for Nextcloud with the php-smbclient PHP extension enabled:
services.nextcloud = {
    enable = true;
    phpExtraExtensions = all: [ all.smbclient ];
    # [Remainder of Nextcloud service configuration omitted]
}
  1. Configure Nextcloud with a SMB external storage.
  2. Attempt to access the configured storage using the web interface.

Expected behavior

The web interface shows the contents of the external storage.

Instead, accessing the storage fails, and the user is repeatedly prompted for login information even though the provided information is correct. The log of the phpfpm-nextcloud service also contains an error message (see additional context below).

Additional context

A possible solution (until either libsmbclient and/or php-smbclient have new releases which address the issue) is overriding the PHP extension with a patched version that works around the regression (which is also mentioned in the corresponding issue in the Nextcloud repo).

The following configuration has solved the issue for me locally:

services.nextcloud.phpPackage = lib.mkForce (pkgs.php.override {
  packageOverrides = final: prev: {
    extensions = prev.extensions // {
      smbclient = prev.extensions.smbclient.overrideAttrs(attrs: {
        src = pkgs.fetchFromGitHub {
          owner = "remicollet";
          repo = "libsmbclient-php";
          # Newest commit on branch "issue-reg-getxattr" at time of writing.
          rev = "b066b6bcd75c8741776d312337f3d69e8484482c";
          sha256 = "sha256-BOY51zYgU2rvMSxbm+N6CwZ6SefY0YktF14zh5uTNU4=";
        };
      });
    };
  };
});

Relevant output of journalctl -xeu phpfpm-nextcloud (with personal information omitted):

Apr 05 05:33:31 cloud libsmbclient[438]: {"reqId":"SpwIzqmSkw1sLqRPlOHo","level":3,"time":"2023-04-05T03:33:31+00:00","remoteAddr":"[...]","user":"[...]","app":"PHP","method":"GET","url":"/index.php/apps/files_external/userglobalstorages/6?testOnly=false","message":"Undefined array key 1 at /nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php#46","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0","version":"26.0.0.11","data":{"app":"PHP"}}
Apr 05 05:33:31 cloud libsmbclient[438]: {"reqId":"SpwIzqmSkw1sLqRPlOHo","level":2,"time":"2023-04-05T03:33:31+00:00","remoteAddr":"[...]","user":"[...]","app":"no app in context","method":"GET","url":"/index.php/apps/files_external/userglobalstorages/6?testOnly=false","message":"{\"Exception\":\"Icewind\\\\SMB\\\\Exception\\\\Exception\",\"Message\":\"Invalid attribute response\",\"Code\":0,\"Trace\":[{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php\",\"line\":69,\"function\":\"stat\",\"class\":\"Icewind\\\\SMB\\\\Native\\\\NativeFileInfo\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php\",\"line\":114,\"function\":\"getSize\",\"class\":\"Icewind\\\\SMB\\\\Native\\\\NativeFileInfo\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/lib/Lib/Storage/SMB.php\",\"line\":191,\"function\":\"stat\",\"class\":\"Icewind\\\\SMB\\\\Native\\\\NativeShare\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/lib/Lib/Storage/SMB.php\",\"line\":348,\"function\":\"getFileInfo\",\"class\":\"OCA\\\\Files_External\\\\Lib\\\\Storage\\\\SMB\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/lib/private/Files/Storage/Common.php\",\"line\":462,\"function\":\"stat\",\"class\":\"OCA\\\\Files_External\\\\Lib\\\\Storage\\\\SMB\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/lib/Lib/Storage/SMB.php\",\"line\":729,\"function\":\"test\",\"class\":\"OC\\\\Files\\\\Storage\\\\Common\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/lib/MountConfig.php\",\"line\":131,\"function\":\"test\",\"class\":\"OCA\\\\Files_External\\\\Lib\\\\Storage\\\\SMB\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/lib/Controller/StoragesController.php\",\"line\":287,\"function\":\"getBackendStatus\",\"class\":\"OCA\\\\Files_External\\\\MountConfig\",\"type\":\"::\",\"args\":[\"*** sensitive parameters replaced ***\"]},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/lib/Controller/UserGlobalStoragesController.php\",\"line\":126,\"function\":\"updateStorageStatus\",\"class\":\"OCA\\\\Files_External\\\\Controller\\\\StoragesController\",\"type\":\"->\",\"args\":[\"*** sensitive parameters replaced ***\"]},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":230,\"function\":\"show\",\"class\":\"OCA\\\\Files_External\\\\Controller\\\\UserGlobalStoragesController\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":137,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/lib/private/AppFramework/App.php\",\"line\":183,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/lib/private/Route/Router.php\",\"line\":315,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/lib/base.php\",\"line\":1055,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\"},{\"file\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/index.php\",\"line\":36,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\"}],\"File\":\"/nix/store/a2y0amfcymlv8vfm0fbjdhcinj6sib0r-nextcloud-26.0.0/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php\",\"Line\":55,\"message\":\"External storage not available: Invalid attribute response\",\"exception\":{},\"CustomMessage\":\"External storage not available: Invalid attribute response\"}","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0","version":"26.0.0.11"}

Notify maintainers

@schneefux @bachp @globin @Ma27

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[root@vulcan:/]# nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.15, NixOS, 23.05 (Stoat), 23.05.20230402.7c65685`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@pulsastrix pulsastrix added the 0.kind: bug Something is broken label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant