Skip to content

External storage #3789

Description

@ddanielww

Steps to reproduce

1.Add SMB share in the external storage app
2.Add host, share and user name and password
3.Try to access the directory and it takes you to the all files page

Expected behaviour

It should map the entire share and this should be accessible through the all file screen. The system should default the remote folder to / and the entire share should mount. It only works if you specify a valid remote folder, however, I need to map the entire drive.

Actual behaviour

The folder is not mounted and can not be accessed through the all file screen, It shows in the external storage section but if you click into it it takes you into all files with no error.

No error in logs

Server configuration

ubuntu:

apache2:

mysql:

PHP 7:

** Nextcloud 11.0.2 **

fresh install:

website

Signing status:

Signing status
Login as admin user into your Nextcloud and access 
http://example.com/index.php/settings/integrity/failed 
paste the results here.

No errors have been found.
<

Activity

  1. enoch85 commented on Mar 31, 2017

    @enoch85
    Member
  2. icewind1991 commented on Mar 31, 2017

    @icewind1991
    Member

    @ddanielww what smb server are you using?

    Can you give the output of occ files_external:export (hiding the password ofc)

  3. enoch85 commented on Mar 31, 2017

    @enoch85
    Member

    @icewind1991 On my customers server:

    [
        {
            "mount_id": 1,
            "mount_point": "\/Teachers Drive T",
            "storage": "\\OCA\\Files_External\\Lib\\Storage\\SMB",
            "authentication_type": "password::password",
            "configuration": {
                "host": "SECRET",
                "share": "teachers$",
                "root": "",
                "domain": "SECRET",
                "user": "SECRET",
                "password": "SECRET"
            },
            "options": {
                "encrypt": true,
                "previews": true,
                "enable_sharing": false,
                "filesystem_check_changes": 1,
                "encoding_compatibility": false
            },
            "applicable_users": [],
            "applicable_groups": [
                "admin",
                "Teachers"
            ]
        }
    ]
    
  4. icewind1991 commented on Mar 31, 2017

    @icewind1991
    Member

    @enoch85 I'm assuming the php-smblient is not installed on the nc server?

    Can you connect to the share manually using smbclient[1] and give me the output of

    allinfo "", allinfo / and allinfo "."

    [1]: smbclient -U $user //$host/$share

  5. enoch85 commented on Mar 31, 2017

    @enoch85
    Member
    __smb: \> allinfo "."
    NT_STATUS_OBJECT_NAME_INVALID getting alt name for \.
    __smb: \> allinfo /
    NT_STATUS_OBJECT_NAME_INVALID getting alt name for \/
    __smb: \> allinfo ""
    altname: \
    create_time:    Fri Dec 23 09:45:32 2011 AEST
    access_time:    Wed Mar 29 13:47:08 2017 AEST
    write_time:     Wed Mar 29 13:47:08 2017 AEST
    change_time:    Wed Mar 29 13:47:08 2017 AEST
    attributes: HSD (16)
    @GMT-2017.03.31-05.02.19
    pathinfo(@GMT-2017.03.31-05.02.19\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.31-02.01.10
    pathinfo(@GMT-2017.03.31-02.01.10\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.30-21.00.06
    pathinfo(@GMT-2017.03.30-21.00.06\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.30-05.01.55
    pathinfo(@GMT-2017.03.30-05.01.55\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.30-02.00.37
    pathinfo(@GMT-2017.03.30-02.00.37\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.29-21.01.19
    pathinfo(@GMT-2017.03.29-21.01.19\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.29-05.01.47
    pathinfo(@GMT-2017.03.29-05.01.47\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.29-02.04.22
    pathinfo(@GMT-2017.03.29-02.04.22\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.28-21.00.39
    pathinfo(@GMT-2017.03.28-21.00.39\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.28-05.01.28
    pathinfo(@GMT-2017.03.28-05.01.28\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.28-02.02.21
    pathinfo(@GMT-2017.03.28-02.02.21\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.27-21.01.10
    pathinfo(@GMT-2017.03.27-21.01.10\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.27-05.00.27
    pathinfo(@GMT-2017.03.27-05.00.27\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.27-02.03.45
    pathinfo(@GMT-2017.03.27-02.03.45\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.26-21.02.28
    pathinfo(@GMT-2017.03.26-21.02.28\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.24-05.01.45
    pathinfo(@GMT-2017.03.24-05.01.45\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.24-02.04.12
    pathinfo(@GMT-2017.03.24-02.04.12\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.23-21.00.07
    pathinfo(@GMT-2017.03.23-21.00.07\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    @GMT-2017.03.23-05.02.54
    pathinfo(@GMT-2017.03.23-05.02.54\) failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
    smb: \> allinfo "."
    NT_STATUS_OBJECT_NAME_INVALID getting alt name for \.
    

    And yes, smb is installed: php-smbclient is already the newest version (0.8.0~rc1-2build1) Ubuntu Server 16.04.2

    The storage's are mounted as root on the Windows Server btw.

    @icewind1991

  6. added a commit that references this issue on Mar 31, 2017
  7. enoch85 commented on Apr 10, 2017

    @enoch85
    Member

    Any news here @icewind1991? The new libs break the function and I don't know PHP that well, so if you could investigate would be awesome!

  8. enoch85 commented on May 21, 2017

    @enoch85
    Member

    @icewind1991 Did you have a look at this yet?

  9. kennethlknight commented on Oct 13, 2017

    @kennethlknight

    any details on this I am having the same issue.

  10. j-ed commented on Oct 14, 2017

    @j-ed
    Contributor

    One more issue ticket covering this problem. I already did further investigations and listed them in the following issue ticket: #6597 .

  11. ujtwr commented on Sep 1, 2018

    @ujtwr

    I have 2 share directories on Windows. One is on "C:" drive, other is on "D:" drive.

    I can mount the directory on "C:" drive, but I can not mount that on "D:" drive.

    I filled in some short code to nextcloud source, and found error message below


    smb: > allinfo ""
    NT_STATUS_OBJECT_NAME_NOT_FOUND getting alt name for \

    I tried to connect the share directory by smbclient command. after loged in, "allinfo" command replied same message.

    On My Windows, "C:" drive was enabled "8.3 short name", but "D:" drive was disabled it. Then, I enabled "8.3 short name" on "D:" drive, delete share directory, made share directory again, which has "short name". I made sure the short name by using Dos command prompt with "dir /x".

    after that, the share directory could be mounted by nextcloud.

    In conclusion, for using smbclient command on nextcloud, we have to enable "8.3 short name", and create short name. To create short name, we must backup, delete and copy all files.... or use "fsutil" command on Windows.

    I understood a cause, but I have no idea how to repair. please feedback my infomation to developer.

  12. CarloApri commented on Mar 16, 2019

    @CarloApri

    How is it possible that this problem is still not fixed without workarounds?
    In owncloud it works just fine!

  13. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Jun 12, 2019
  14. jstruebel commented on May 12, 2020

    @jstruebel

    I can confirm this issue is still present. I'm able to work around it by entering "/folder/.." for the "Remote subfolder" field where "folder" is some folder that exists on the share. I'm accessing a share on another linux server via samba, same version as smbclient on the nextcloud server.

    This is with the following versions (fresh install):
    Nextcloud: 17.0.6
    smbclient: 4.5.16-Debian
    php-smbclient: 1.0.0
    php: 7.3.17
    nginx: 1.10.3

  15. leameiners commented on Jul 24, 2020

    @leameiners

    Hello, we have run into this same problem when using a failover cluster for the file server since in this setup backwards 8.3 compatibility cannot be enabled on the shares.

    We've managed to find a workaround modifying the source code so that it doesnt rely on the "allinfo" command via smbclient but on "dir", as the former does not work on shares without 8.3 compatibility.

    I leave the code below for review. It'd be great if this fix was merged into the code base as it seems we are not the only ones with this issue.

    ====================================================================
    FILE: apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php

    • Added function dirRoot:

        public function dirRoot() {
                $output = $this->execute('dir /');
                return $this->parser->parseRootDir($output, $path, function ($path) {
                        return $this->getAcls($path);
                });
        }
      

    Comment: This function is a helper function that is meant to do the same as the dir function, but restricted to the case of listing the root directory. It could be unified with the dir function but doing so would require modifying the behaviour of this for this special case. This function uses parseRootDir which is explained below.

    • Modified the stat function, as follows:

        public function stat($path) {
                // some windows server setups don't seem to like the allinfo command
                // use the dir command instead to get the file info where possible
                if ($path !== "" && $path !== "/") {
                        $parent = dirname($path);
                        $dir = $this->dir($parent);
                        $file = array_values(array_filter($dir, function (IFileInfo $info) use ($path) {
                                $infoPath = $info->getPath();
                                if ( substr( $infoPath, 0, 2 ) === "//") {
                                        $infoPath = substr($infoPath, 1);
                                }
                                return $infoPath === $path;
                        }));
                        if ($file) {
                                return $file[0];
                        }
                } else {
                        $dir = $this->dirRoot();
                        $file = array_values(array_filter($dir, function (IFileInfo $info) use ($path) {
                                return $info->getPath() === "/";
                        }));
                        if ($file) {
                                return $file[0];
                        }
                }
      
                $escapedPath = $this->escapePath($path);
                $output = $this->execute('allinfo ' . $escapedPath);
                // Windows and non Windows Fileserver may respond different
                // to the allinfo command for directories. If the result is a single
                // line = error line, redo it with a different allinfo parameter
                if ($escapedPath == '""' && count($output) < 2) {
                        $output = $this->execute('allinfo ' . '"."');
                }
                if (count($output) < 3) {
                        $this->parseOutput($output, $path);
                }
                $stat = $this->parser->parseStat($output);
                return new FileInfo($path, basename($path), $stat['size'], $stat['mtime'], $stat['mode'], function () use ($path) {
                        return $this->getAcls($path);
                });
        }
      

    Comment:

    • The main if was modified as follows:
      • There is a bug in the getPath function: when it is called for a file living in the / (root directory) it returns the filename preceeded with // when it should be returned with a single /, to be able to match it when calling array_filter; hence the substr workaround to handle this case
      • An else clause was added to handle executing "dir /" and getting the information from there instead of the command "allinfo /", as the latter fails when the server doesn't support 8.3 filename encoding (which is forcibly so when using a failover setup for example). It is here we use the dirRoot specific function and have hardcoded the base path of this case for it to match.

    =====================================================================
    FILE: apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php

    • Added function parseRootDir

        public function parseRootDir($output, $basePath, callable $aclCallback) {
                //last line is used space
                array_pop($output);
                $regex = '/^\s*(\.)\s\s\s\s+(?:([NDHARS]*)\s+)?([0-9]+)\s+(.*)$/';
                //2 spaces, . dot directory, optional type, size, date
                $content = [];
                foreach ($output as $line) {
                        if (preg_match($regex, $line, $matches)) {
                                list(, $name, $mode, $size, $time) = $matches;
                                if ($name == '.') {
                                        $mode = $this->parseMode($mode);
                                        $time = strtotime($time . ' ' . $this->timeZone);
                                        $path = '/';
                                        $content[] = new FileInfo($path, $name, $size, $time, $mode, function () use ($aclCallback, $path) {
                                                return $aclCallback($path);
                                        });
                                }
                        }
                }
                return $content;
        }
      

    Comment:

    • This function is similar to parseDir except for:
      • modified regex to find the "." dot directory (as this is the root)
      • modified if accordingly
      • and hardcoded return path to / as the "." is current and not root directory.

    cheers,
    Leandro.-

  16. added
    1. to developAccepted and waiting to be taken care of
    and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Aug 20, 2020
  17. szaimen commented on Nov 26, 2022

    @szaimen
    Contributor

    Hi, please update to at least 23.0.12 and report back if it fixes the issue. Thank you!

  18. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    and removed
    1. to developAccepted and waiting to be taken care of
    on Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions