owncloud / owncloud/core

Service Unavailable reported for remote storage (SMB)

Open
#38,213 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type:Bug
Dominant language
PHP
Stars
8.8k
Forks
2.1k
Avg merge
20h 7m
Merged PRs (30d)
41

Description

Steps to reproduce
  1. As an administrator, create a storage located on SMB share, server name = SERVER-NAME, share = 3000-PO$ ($ means hidden), path = \folder\folder with space in name\OwnCloud, username and password as required to access the share
  2. Give access to that remote storage to a regular user with read & write permissions
  3. Login as that regular user and try to access the remote storage
  4. Most of the time, an HTTP code 503 "Service Unavailable" is returned by OwnCloud, sometimes (rarely) the remote storage is displayed empty and it's reported that the user does not have write access
  5. The URL looks like https://files.sion.ch/remote.php/webdav/YourShareName
  6. Look at the logs under Administration / General. You should find these 2 lines related to that unavailable service message:
    {"reqId":"X9ceI02zp2VxeY5yLhXfkwAAABE","level":4,"time":"2020-12-14T08:11:15+00:00","remoteAddr":"172.24.2.19","user":"88E57097-8AFB-4A0B-81A8-C9BB56F05E91","app":"webdav","method":"GET","url":"/remote.php/webdav/3000-PO-OwnCloud-PoliceRurale-W","message":"Exception: HTTP/1.1 503 Could not open file: {"Exception":"Sabre\\DAV\\Exception\\ServiceUnavailable","Message":"Could not open file","Code":0,"Trace":"#0 \/var\/www\/html\/owncloud\/lib\/composer\/sabre\/dav\/lib\/DAV\/CorePlugin.php(85): OCA\\DAV\\Connector\\Sabre\\File->get()\n#1 \/var\/www\/html\/owncloud\/lib\/composer\/sabre\/event\/lib\/WildcardEmitterTrait.php(89): Sabre\\DAV\\CorePlugin->httpGet()\n#2 \/var\/www\/html\/owncloud\/lib\/composer\/sabre\/dav\/lib\/DAV\/Server.php(470): Sabre\\DAV\\Server->emit()\n#3 \/var\/www\/html\/owncloud\/lib\/composer\/sabre\/dav\/lib\/DAV\/Server.php(251): Sabre\\DAV\\Server->invokeMethod()\n#4 \/var\/www\/html\/owncloud\/lib\/composer\/sabre\/dav\/lib\/DAV\/Server.php(319): Sabre\\DAV\\Server->start()\n#5 \/var\/www\/html\/owncloud\/apps\/dav\/appinfo\/v1\/webdav.php(65): Sabre\\DAV\\Server->exec()\n#6 \/var\/www\/html\/owncloud\/remote.php(165): require_once('\/var\/www\/html\/o...')\n#7 {main}","File":"\/var\/www\/html\/owncloud\/apps\/dav\/lib\/Connector\/Sabre\/File.php","Line":397}"}

{"reqId":"X9ceVOvTXsF8YbIcvb5vIgAAAUY","level":3,"time":"2020-12-14T08:12:04+00:00","remoteAddr":"172.24.2.19","user":"88E57097-8AFB-4A0B-81A8-C9BB56F05E91","app":"PHP","method":"GET","url":"/remote.php/webdav/3000-PO-OwnCloud-PoliceRurale-W","message":"fread() expects parameter 1 to be resource, bool given at /var/www/html/owncloud/lib/private/Files/Storage/Wrapper/Encryption.php#897"}

Script File.php is responsible for that behavior:
395 $res = $this->fileView->fopen($viewPath, 'rb');
396 if ($res === false) {
397 throw new ServiceUnavailable("Could not open file ");
398 }
399 return $res;

But when we look at the Encryption.php file, using var_dump on $handle and $path, you see that $path is empty and $handle is false (bool instead of resource).

Expected behaviour

The remote storage should open and display existing files

Actual behaviour

"Service Unavailable" is reported

Server configuration

Operating system:
CentOS Linux release 8.3.2011

Web server:
Apache2

Database:
MariaDB

PHP version:
php-pecl-imagick-3.4.4-10.el8.remi.7.4.x86_64
php-gd-7.4.13-1.el8.remi.x86_64
php-sodium-7.4.13-1.el8.remi.x86_64
php-mysqlnd-7.4.13-1.el8.remi.x86_64
php-pecl-mcrypt-1.0.4-1.el8.remi.7.4.x86_64
php74-runtime-1.0-3.el8.remi.x86_64
php74-php-phpiredis-1.0.1-1.el8.remi.x86_64
php-pecl-memcache-4.0.5.2-1.el8.remi.7.4.x86_64
php-pecl-apcu-5.1.19-1.el8.remi.7.4.x86_64
oniguruma5php-6.9.6-1.el8.remi.x86_64
php-7.4.13-1.el8.remi.x86_64
php74-php-ldap-7.4.13-2.el8.remi.x86_64
php-ldap-7.4.13-1.el8.remi.x86_64
php-json-7.4.13-1.el8.remi.x86_64
php74-php-common-7.4.13-2.el8.remi.x86_64
php-fpm-7.4.13-1.el8.remi.x86_64
php-cli-7.4.13-1.el8.remi.x86_64
php74-php-xmlrpc-7.4.13-2.el8.remi.x86_64
php-intl-7.4.13-1.el8.remi.x86_64
php-common-7.4.13-1.el8.remi.x86_64
php-pdo-7.4.13-1.el8.remi.x86_64
php-opcache-7.4.13-1.el8.remi.x86_64
php-pecl-zip-1.19.2-1.el8.remi.7.4.x86_64
php-mbstring-7.4.13-1.el8.remi.x86_64
php74-php-process-7.4.13-2.el8.remi.x86_64
php74-php-smbclient-1.0.0-7.el8.remi.x86_64
php74-php-json-7.4.13-2.el8.remi.x86_64
php-smbclient-1.0.0-7.el8.remi.7.4.x86_64
php74-php-xml-7.4.13-2.el8.remi.x86_64
php-xml-7.4.13-1.el8.remi.x86_64

ownCloud version: (see ownCloud admin page)
10.5.0.10

Updated from an older ownCloud or fresh install:
Fresh install

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the SMB remote-storage access steps, then inspect apps/dav/lib/Connector/Sabre/File.php around line 397 and lib/private/Files/Storage/Wrapper/Encryption.php around line 897. Trace why opening the existing file produces an empty path and false handle. Done means the remote storage opens existing files for regular users without the 503 or write-access error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.