core icon indicating copy to clipboard operation
core copied to clipboard

Unable to delete files inside folders shared by link

Open mcastroSG opened this issue 10 years ago • 22 comments

Steps to reproduce

  1. On server A create a new folder (aka folder1)
  2. On server A create a new file inside folder1 (aka file1)
  3. On server A share by link folder1 (allow edit checked)
  4. Paste link on browser, click on Add to your owncloud and fill ownCloud field with server B url
  5. On server B accept shared folder
  6. On server B navigate inside folder1 and check available options for file1

Expected behaviour

Shared by link should have the same behaviour than shared option

Shared by link: screen shot 2016-05-27 at 09 25 53

Shared:

screen shot 2016-05-27 at 09 40 45

Actual behaviour

As user who accepts shared items, we are not able to remove files inside folder shared by link. On 9.0.2 it works fine, shows the same options.

Server configuration

Operating system: Ubuntu 14.04.1 LTS Web server: Apache2 Database: Server version: 5.5.46-0ubuntu0.14.04.2 (Ubuntu) PHP version: PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46 ownCloud version: (see ownCloud admin page) ownCloud Enterprise Edition 9.1.0 beta 1 (testing)

The content of config/config.php:

<?php
$CONFIG = array (
  'updatechecker' => false,
  'supportedDatabases' => 
  array (
    0 => 'mysql',
    1 => 'pgsql',
    2 => 'oci',
  ),
  'instanceid' => 'oco48z2585bc',
  'passwordsalt' => 'ZZZZ',
  'secret' => 'XXXXX',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'XXXXXX',
  ),
  'datadirectory' => '/opt/owncloud/data',
  'overwrite.cli.url' => 'XXXX',
  'dbtype' => 'mysql',
  'version' => '9.1.0.5',
  'dbname' => 'owncloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => '',
  'dbuser' => 'oc_admin',
  'dbpassword' => '*** removed for security reasons',
  'logtimezone' => 'UTC',
  'installed' => true,
  'license-key' => '*** removed for security reasons',
);

Are you using encryption:

No

@rullzer

mcastroSG avatar May 27 '16 08:05 mcastroSG

Possibly an issue with share permissions, @rullzer can you have a look ?

PVince81 avatar Jun 02 '16 13:06 PVince81

Now this is weird... the permission in the DB are 7 when you enable editing... which actually makes the permissions on the mounted link correct. The question is why is there a delete on the link share page. Since we don't allow it.

And why do we allow the files to be deleted.

rullzer avatar Jun 06 '16 12:06 rullzer

ah so it is actually the webview that is doing fishy things... because allowediting never sets delete permissions. But the dav endpoint hapily sets them.

@PVince81 I suggest to fix the web view to reflect permissions properly. Then we can decide separatly if we want 'allow editing' to also mean delete

rullzer avatar Jun 06 '16 12:06 rullzer

@rullzer sounds good

PVince81 avatar Jun 06 '16 12:06 PVince81

Ok lets do it :)

rullzer avatar Jun 06 '16 12:06 rullzer

PR in #24990

rullzer avatar Jun 06 '16 12:06 rullzer

So the thing here is that the public view is being the bad boy. When allowing edit on the link we never set the DELETE permissions. So then we should not allow delete (which the mount correctly does not show).

This is also in line with the edit permission on 'normal' shares. Where edit and delete are separated.

So the real bug here is that you can delete files on and editable link share while those permissions are not granted!

rullzer avatar Jun 08 '16 18:06 rullzer

@rullzer when we introduced the ability to create/update/delete files in the web UI of the share link in 9.0, these were activated when the "allow editing" permission was given. Not sure whether it properly set the permission value to 31 back then.

PVince81 avatar Jun 09 '16 08:06 PVince81

@PVince81 this was also already the case in 8.2 https://github.com/owncloud/core/blob/stable8.2/core/js/shareitemmodel.js#L195

rullzer avatar Jun 09 '16 11:06 rullzer

Reopening as the linked PR did not fix the issue, it just made it inconsistent.

PVince81 avatar Jun 10 '16 12:06 PVince81

it just made it inconsistent.

It made it consistent :wink: But fair enough.

rullzer avatar Jun 13 '16 06:06 rullzer

So now the big questions. Should edit permissions also allow deletion of files?

rullzer avatar Jun 13 '16 06:06 rullzer

Looks like "share with link" also doesn't set the reshare permissions: https://github.com/owncloud/core/issues/25221

@rullzer would it make sense to simply make new link shares use the permissions 31 at creation time ?

There's another ticket here to introduce CRUDS permissions for link shares too: https://github.com/owncloud/core/issues/20699

PVince81 avatar Jun 22 '16 14:06 PVince81

Okay, so for reference I tested 8.2 to 9.1 with fed shares and link shares, as created in the web UI. These are the permissions that are created:

+---------------------------------------+-------------+
| name                                  | permissions |
+---------------------------------------+-------------+
| 8.2 fed share readonly                |           1 |
| 8.2 fed share readwrite               |           7 |
| 8.2 link share readonly               |           1 |
| 8.2 link share readwrite              |           7 |
| 9.0.2 fed share readonly              |           1 |
| 9.0.2 fed share readwrite             |           7 |
| 9.0.2 link share readonly             |           1 |
| 9.0.2 link share readwrite            |           7 |
| 9.1.0 fed share readonly              |           1 |
| 9.1.0 fed share readonly + can share  |          17 |
| 9.1.0 fed share readwrite             |          15 |
| 9.1.0 fed share readwrite + can share |          31 |
| 9.1.0 link share readonly             |           1 |
| 9.1.0 link share readwrite            |           7 |
+---------------------------------------+-------------+

PVince81 avatar Jun 22 '16 15:06 PVince81

More ideas:

  • [ ] make link shares use permissions 15 for readwrite (no reshare) and 1 for readonly
  • [ ] repair step to adjust the permissions of existing link shares

But then also the question about clients, should they also be adjusted to send the same permissions ?

PVince81 avatar Jun 22 '16 15:06 PVince81

also I noticed that from an API perspective, the link share permission is enforced to be either 1 or 7 regardless of what a client sends. So maybe this enforcing needs to be adjusted too in case clients still sent only 1 or 7 and we'd enforce it to 1 or 15 ?

PVince81 avatar Jun 22 '16 16:06 PVince81

I've tried to do a federated share to 9.1 with all permissions, then in 9.1 share that file with an interal user again with all permissions and that internal user can't get the file.

Logs:

{"reqId":"70k1flvu2dJigxbMfxij","remoteAddr":"172.17.42.1","app":"filesystem","message":"Storage wrapper 'sharePermissions' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.","level":2,"time":"2016-06-22T22:26:23+00:00","method":"PROPFIND","url":"\/public.php\/webdav\/","user":"--"}
{"reqId":"cODQWrA0qlurWJ68ttFD","remoteAddr":"172.17.42.1","app":"filesystem","message":"Storage wrapper 'sharePermissions' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.","level":2,"time":"2016-06-22T22:26:25+00:00","method":"PROPFIND","url":"\/public.php\/webdav\/","user":"--"}
{"reqId":"cQpI+VmkLrJv\/Ngo6Rq0","remoteAddr":"172.17.42.1","app":"filesystem","message":"Storage wrapper 'sharePermissions' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.","level":2,"time":"2016-06-22T22:26:25+00:00","method":"GET","url":"\/public.php\/webdav\/","user":"--"}
{"reqId":"Gp5TkJRmMSbzfIXiFN4Z","remoteAddr":"172.17.42.1","app":"webdav","message":"Exception: {\"Message\":\"HTTP\\\/1.1 503 Could not open file\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\ServiceUnavailable\",\"Code\":0,\"Trace\":\"#0 \\\/opt\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(83): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->get()\\n#1 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpGet(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/opt\\\/owncloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#3 \\\/opt\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(459): Sabre\\\\Event\\\\EventEmitter->emit('method:GET', Array)\\n#4 \\\/opt\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(248): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#5 \\\/opt\\\/owncloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(56): Sabre\\\\DAV\\\\Server->exec()\\n#6 \\\/opt\\\/owncloud\\\/remote.php(164): require_once('\\\/opt\\\/owncloud\\\/a...')\\n#7 {main}\",\"File\":\"\\\/opt\\\/owncloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":306,\"User\":\"s1sharee\"}","level":4,"time":"2016-06-22T22:26:28+00:00","method":"GET","url":"\/remote.php\/webdav\/qwerty2.txt","user":"s1sharee"}

All federated tests involving a 9.1 server (until now) have failed beacause of this. (Rechecking with 9.0 to confirm; it will take a while)

jvillafanez avatar Jun 23 '16 07:06 jvillafanez

@jvillafanez federated shares do work for me in 9.1, but you're right about that warning message. I also get it and didn't notice before.

Likely related to the latest change from https://github.com/owncloud/core/issues/24990

PVince81 avatar Jun 23 '16 08:06 PVince81

The message disappears if I revert https://github.com/owncloud/core/pull/24990 locally

PVince81 avatar Jun 23 '16 08:06 PVince81

That warning was added recently. It is because we add the storage wrapper at a place we are not supposed to. But to be fair we also did that before.

rullzer avatar Jun 23 '16 11:06 rullzer