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

External storage #3789

Closed
ddanielww opened this issue Mar 9, 2017 · 14 comments
Closed

External storage #3789

ddanielww opened this issue Mar 9, 2017 · 14 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug feature: external storage needs info

Comments

@ddanielww
Copy link

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.
<
@enoch85
Copy link
Member

enoch85 commented Mar 31, 2017

cc @icewind1991

@icewind1991
Copy link
Member

@ddanielww what smb server are you using?

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

@enoch85
Copy link
Member

enoch85 commented Mar 31, 2017

@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"
        ]
    }
]

@icewind1991
Copy link
Member

icewind1991 commented Mar 31, 2017

@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

@enoch85
Copy link
Member

enoch85 commented Mar 31, 2017

__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

@enoch85
Copy link
Member

enoch85 commented Apr 10, 2017

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!

@enoch85
Copy link
Member

enoch85 commented May 21, 2017

@icewind1991 Did you have a look at this yet?

@kennethlknight
Copy link

any details on this I am having the same issue.

@j-ed
Copy link
Contributor

j-ed commented Oct 14, 2017

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

@ujtwr
Copy link

ujtwr commented Sep 1, 2018

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.

@carlox97
Copy link

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

@skjnldsv skjnldsv added the 0. Needs triage Pending check for reproducibility or if it fits our roadmap label Jun 12, 2019
@jstruebel
Copy link

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

@leameiners
Copy link

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.-

@skjnldsv skjnldsv added 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Aug 20, 2020
@szaimen
Copy link
Contributor

szaimen commented Nov 26, 2022

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

@szaimen szaimen added needs info 0. Needs triage Pending check for reproducibility or if it fits our roadmap and removed 1. to develop Accepted and waiting to be taken care of labels Nov 26, 2022
@szaimen szaimen closed this as completed Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug feature: external storage needs info
Projects
None yet
Development

No branches or pull requests