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

getSourcePath broken for External storage (Local)? #29770

Closed
JimH44 opened this issue Nov 18, 2021 · 10 comments
Closed

getSourcePath broken for External storage (Local)? #29770

JimH44 opened this issue Nov 18, 2021 · 10 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@JimH44
Copy link

JimH44 commented Nov 18, 2021

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.

I prepared this bug report using the Issue reporting app in NC:

Steps to reproduce

  1. Create External storage (local) pointing to /home/ltadman/LTSync (where "ltadmin" is the name of the admin user of NextCloud.)
    /home/ltadmin/LTSync is owned by user running apache2 (www-data) and the group is the same.
    (nextcloud.occ files_external:list shows
    | Mnt ID | Mnt Pt | Storage | Auth Type | Configuration | Options | Users | Groups |
    +---------+---------+------------+--------------+------------------------------------+------------------------------------+---------+----------+
    | 3 | /LTSync | Local | None | datadir: "/home/ltadmin/LTSync" | enable_sharing: T, previews: F | ltadmin| |)
    Check that user www-data can list properties and see contents of all folders from leaf to root with commands like
    sudo -u www-data ls -ld /home/ltadmin/LTSync
    Even the user nobody can see inside all folders from root to leaf.
  2. Within NC as admin user, try to create a folder inside this folder.

Expected behaviour

NC should create new folder inside /home/ltadmin/LTSync with the name requested.

Actual behaviour

Administration->Logging shows:
[PHP] Error: opendir(/home/ltadmin/LTSync/): Failed to open directory: Permission denied at /snap/nextcloud/28586/htdocs/lib/private/Files/Storage/Local.php#135

PROPFIND /remote.php/dav/files/ltadmin/
from 14.200.30.196 by ltadmin at 2021-11-18T09:34:53+00:00

Server configuration detail

Operating system: Linux 5.11.0-40-generic #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64

Webserver: Apache (fpm-fcgi)

Database: mysql 8.0.26

PHP version:

8.0.11
Modules loaded: Core, date, libxml, openssl, pcre, zlib, bcmath, bz2, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, gmp, SPL, iconv, intl, json, ldap, mbstring, pcntl, PDO, session, posix, Reflection, standard, SimpleXML, mysqlnd, exif, tokenizer, xml, xmlreader, xmlwriter, zip, pdo_mysql, cgi-fcgi, redis, Zend OPcache

Nextcloud version: 22.2.0 - 22.2.0.2

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

Where did you install Nextcloud from: Downloaded stancard snap file from standard NC website.

Signing status

Array
(
)

List of activated apps
Enabled:
 - accessibility: 1.8.0
 - activity: 2.15.0
 - circles: 22.1.1
 - cloud_federation_api: 1.5.0
 - comments: 1.12.0
 - contacts: 4.0.6
 - contactsinteraction: 1.3.0
 - dashboard: 7.2.0
 - dav: 1.19.0
 - federatedfilesharing: 1.12.0
 - federation: 1.12.0
 - files: 1.17.0
 - files_external: 1.13.0
 - files_pdfviewer: 2.3.0
 - files_rightclick: 1.1.0
 - files_sharing: 1.14.0
 - files_trashbin: 1.12.0
 - files_versions: 1.15.0
 - files_videoplayer: 1.11.0
 - firstrunwizard: 2.11.0
 - guests: 2.1.0
 - issuetemplate: 0.7.0
 - logreader: 2.7.0
 - lookup_server_connector: 1.10.0
 - nextcloud_announcements: 1.11.0
 - notifications: 2.10.1
 - oauth2: 1.10.0
 - password_policy: 1.12.0
 - photos: 1.4.0
 - privacy: 1.6.0
 - provisioning_api: 1.12.0
 - recommendations: 1.1.0
 - serverinfo: 1.12.0
 - settings: 1.4.0
 - sharebymail: 1.12.0
 - support: 1.5.0
 - survey_client: 1.10.0
 - systemtags: 1.12.0
 - text: 3.3.0
 - theming: 1.13.0
 - twofactor_backupcodes: 1.11.0
 - user_status: 1.2.0
 - viewer: 1.6.0
 - weather_status: 1.2.0
 - workflowengine: 2.4.0
Disabled:
 - admin_audit
 - encryption
 - user_ldap

Configuration (config/config.php)
{
    "apps_paths": [
        {
            "path": "\/snap\/nextcloud\/current\/htdocs\/apps",
            "url": "\/apps",
            "writable": false
        },
        {
            "path": "\/var\/snap\/nextcloud\/current\/nextcloud\/extra-apps",
            "url": "\/extra-apps",
            "writable": true
        }
    ],
    "supportedDatabases": [
        "mysql"
    ],
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "memcache.local": "\\OC\\Memcache\\Redis",
    "redis": {
        "host": "***REMOVED SENSITIVE VALUE***",
        "port": 0
    },
    "log_type": "file",
    "logfile": "\/var\/snap\/nextcloud\/current\/logs\/nextcloud.log",
    "logfilemode": 416,
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "localhost",
        "files.lingtransoft.info"
    ],
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "dbtype": "mysql",
    "version": "22.2.0.2",
    "overwrite.cli.url": "http:\/\/localhost",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbport": "",
    "dbtableprefix": "oc_",
    "mysql.utf8mb4": true,
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "installed": true,
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "maintenance": false,
    "app_install_overwrite": [
        "issuetemplate"
    ]
}

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

Are you using encryption:

Are you using an external user-backend, if yes which one: I don't think so.

Client configuration

Browser: Chromium

Operating system:

Logs

Web server error log
Insert your web server log here 
Nextcloud log
[PHP] Error: opendir(/home/ltadmin/LTSync/): Failed to open directory: Permission denied at /snap/nextcloud/28586/htdocs/lib/private/Files/Storage/Local.php#135

PROPFIND /remote.php/dav/files/ltadmin/
from 14.200.30.196 by ltadmin at 2021-11-18T09:34:53+00:00
Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log
c) ...

My comments

The error message comes from line 135 of the file named, which contains:
return opendir($this->getSourcePath($path))
which is overloading the standard PHP opendir function.

When you look at the function getSourcePath, (line 446) it seems to be adding $path to the datadir, which, I am guessing, would be
/var/snap/nextcloud/common/nextcloud/data/ltadmin/files
That would look for the folder
/var/snap/nextcloud/common/nextcloud/data/ltadmin/files/home/ltuser/LTSync
which doesn't exixt, instead of
/home/ltuser/LTSync
Is that what is happening?
Thanks for thinking about these things.

@JimH44 JimH44 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Nov 18, 2021
@solracsf
Copy link
Member

This is very similar to #28473
Can you try the same fix? So return opendir($path)?

@szaimen
Copy link
Contributor

szaimen commented Nov 18, 2021

@szaimen szaimen closed this as completed Nov 18, 2021
@JimH44
Copy link
Author

JimH44 commented Nov 18, 2021

@szaimen , I don't think it's right to close this issue, because I ran the command you suggested
sudo snap connect nextcloud:removable-media
even though I was not trying to open a folder within /media or /mnt
and it made no difference.
Could you please re-open the issue, and I'll work on the suggestion from @acsfer .

@szaimen
Copy link
Contributor

szaimen commented Nov 18, 2021

even though I was not trying to open a folder within /media or /mnt

The Nextcloud Snap appliance only supports accessing directories in /media or /mnt...

@JimH44
Copy link
Author

JimH44 commented Nov 18, 2021

@szaimen , well why did nobody tell us that?
That's a killer for my application.
So, it seems to me, the documentation that suggests using the snap version should warn us that the behaviour of the two versions is different, or we should improve the snap version so that it handles local folders anywhere.
Do you know why the snap version is restricted to /media or /mnt?

@szaimen
Copy link
Contributor

szaimen commented Nov 18, 2021

@JimH44
Copy link
Author

JimH44 commented Nov 18, 2021

Thanks, @szaimen , I'll follow up on those two links.

To report on trying to use a folder within /media:

I copied the test folder tree from /home/ltadmin to /media and made sure the ownership was www-data:www-data and that the permissions are right for that user to create files and folders there.
Then I remade the External storage (Local), and it is not set to read-only.
I can now see the contents of the test folder, plain files, directories and their contents.
But when I try to create files or folders there I get errors.
So even the restricted usage in /media or /mnt doesn't allow file creation.

Do you think the non-snap version would behave better?
Seems it would be a lot more complicated to install (the snap is so easy :-)), but I may need to try that.

@szaimen
Copy link
Contributor

szaimen commented Nov 19, 2021

made sure the ownership was www-data:www-data

The ownership needs to be root:root in case of the snap

@JimH44
Copy link
Author

JimH44 commented Nov 19, 2021

@szaimen , can you pls point me to where that is documented. It's hard for us users to get things right when the snap version departs from what is documented for the other version at so many points.
And I've been around computers long enough to know that we humans have to get every thing right!

@szaimen
Copy link
Contributor

szaimen commented Nov 19, 2021

It must be documented somewhere here: https://github.com/nextcloud-snap/nextcloud-snap

For further questions please ask here: https://help.nextcloud.com/tags/c/support/appliances-docker-snappy-vm/33/snap
Or feel free to create an issue here if you think the snaps docs are uncomplete: https://github.com/nextcloud-snap/nextcloud-snap/issues

I am unsubscribing now!

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
Projects
None yet
Development

No branches or pull requests

3 participants