Skip to content

Add server<->server sharing - #8399

Merged
icewind1991 merged 47 commits into
masterfrom
server-server-sharing
Jun 17, 2014
Merged

icewind1991 merged 47 commits into
masterfrom
server-server-sharing

Conversation

@icewind1991

Copy link
Copy Markdown
Contributor

Add support for adding public links from someone to your own owncloud

Fixes #7221

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Currently, to test this you need to manually add the share to the share_external table, i.e:

Hmm - up to now we did store mount information in mount.json files. Wouldn't if be consistent to store these mount information in there as well?
Or start to move all mount information into the database.

I'm a big fan of consistent design 😉

@icewind1991

Copy link
Copy Markdown
Contributor Author

I don't want to "clutter" the mount configuration with automatically added entries.

imo, the cross server shares are closer to regular shares then external storages to the user, and such they should not be part of the external storage configuration.

Besides, it's consistent with regular sharing which also generates it's mounts from the database 😉

Comment thread apps/files_sharing/appinfo/app.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move this to the server container?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@icewind1991 can you please have a look at my comments? THX

@icewind1991

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 @PVince81 @schiesbn can you have a look at this.

Steps to test:

  • Create a public share of a file or folder and open it in the browser
  • Click the "Save to ownCloud" button
  • Enter the location of a different instance (i.e. "example.com/owncloud")
  • After being redirected and logging in accept the share

@karlitschek

Copy link
Copy Markdown
Contributor

is is possible to "mount" a public link that I got from somewhere into my private ownCloud?
This is the main UI and workflow that we need.

@PVince81

Copy link
Copy Markdown
Contributor

@icewind1991 just had a quick test with the steps you mentioned.
I input the target ownCloud it did redirect there, but the URL became this:
http://localhost:8080/owncloud/index.php/apps/files#remote=http%3A%2F%2Ftest%2Fvincent&token=c951f5b1d0ab059f4ca2d018323502ee&owner=root&name=pics

The server "http://test/vincent" is the one where the public share is and "http://localhost:8080/owncloud" is the one I tried adding it too.

Note that I was already logged in.
Could be a bug or maybe due to the sidebar code ? (I see you rebased recently)

@schiessle

Copy link
Copy Markdown
Contributor

I gave it a try, what I observed:

  • for a single file share the "Save to ownCloud" button doesn't work.
  • for a folder I get redirected to the login page, then I enter my username password. A dialog ask if I want to mount the share. I click in "yes" nothing happens. After page reload the file list is empty, no server-to-server mount point and no local files

apache error log:

[Mon May 19 17:10:20 2014] [error] [client ::1] PHP Fatal error:  Class 'OC\\Files\\Storage\\DAV' not found in /home/src/owncloud/web/oc2/apps/files_sharing/lib/external/storage.php on line 14, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP Stack trace:, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   1. {main}() /home/src/owncloud/web/oc2/index.php:0, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   2. OC::handleRequest() /home/src/owncloud/web/oc2/index.php:28, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   3. OC\\Route\\Router->match() /home/src/owncloud/web/oc2/lib/base.php:708, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   4. call_user_func() /home/src/owncloud/web/oc2/lib/private/route/router.php:206, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   5. OC::loadAppScriptFile() /home/src/owncloud/web/oc2/lib/private/route/router.php:206, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   6. require_once() /home/src/owncloud/web/oc2/lib/base.php:794, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   7. OC\\Files\\Filesystem::getFileInfo() /home/src/owncloud/web/oc2/apps/files/ajax/list.php:9, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   8. OC\\Files\\View->getFileInfo() /home/src/owncloud/web/oc2/lib/private/files/filesystem.php:717, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP   9. OC\\Files\\Filesystem::getStorage() /home/src/owncloud/web/oc2/lib/private/files/view.php:847, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP  10. OC\\Files\\Mount\\Mount->getStorage() /home/src/owncloud/web/oc2/lib/private/files/filesystem.php:244, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP  11. OC\\Files\\Mount\\Mount->createStorage() /home/src/owncloud/web/oc2/lib/private/files/mount/mount.php:99, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP  12. class_exists() /home/src/owncloud/web/oc2/lib/private/files/mount/mount.php:81, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP  13. OC\\Autoloader->load() /home/src/owncloud/web/oc2/lib/private/files/mount/mount.php:0, referer: http://localhost/oc2/index.php/apps/files
[Mon May 19 17:10:20 2014] [error] [client ::1] PHP  14. require_once() /home/src/owncloud/web/oc2/lib/autoloader.php:143, referer: http://localhost/oc2/index.php/apps/files

Other stuff which needs to be tested after the problem above is solved:

  • does it work with single file shares
  • does it work with encryption enabled for the user who shared the folder
  • does it work with encryption enabled for user who mounted the share
  • does it work with encryption enabled on both sides

@icewind1991 If there is something I can help with, feel free to get in contact with me on github, irc or by mail.

@icewind1991

Copy link
Copy Markdown
Contributor Author

The "Save to ownCloud" button is broken for single files due to the file sidebar by @PVince81 which causes js errors on the public share page.

PHP Fatal error: Class 'OC\\Files\\Storage\\DAV' not found

Do you have the external storage app enabled?

@schiessle

Copy link
Copy Markdown
Contributor

Do you have the external storage app enabled?

No, only following apps are enabled: Activity, Deleted Files, Pictures, Share Files, Text Editor, Versions

@schiessle

Copy link
Copy Markdown
Contributor

After I enabled the external storage it works, we should probably check this before we mount the public link.

  • don't allow user to mount public link if external storage app is disabled

@schiessle

Copy link
Copy Markdown
Contributor

Further tests:

  • share a folder without password, mount it, then owner adds password to share -> recipient can no longer read the mounted files -> expected behavior mount should still work
  • create share with password protection -> open the link -> enter password -> try to mount share -> doesn't work -> expected behavior user should be able to mount the share
  • if the owner removes the link share the server-to-server share should be unmounted,
  • after mounting a share I can edit files and upload new files, even if "allow public upload" wasn't enabled by the owner -> expected behavior file/folder should be read only
  • generate unique name if a file folder with the same name already exists, currently the local file will be covered by the mount point

@schiessle

Copy link
Copy Markdown
Contributor

Added a commit to fix server-to-server sharing if the owner uses encryption

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you write the mount point relative to /data to the share_external table? The targets in oc_share are relative to data/user/files. I think we should use the same root and the same format for the mountpoints.

@schiessle

Copy link
Copy Markdown
Contributor

Found another issue, sorry 😄

  • wrong path to public.php if ownCloud is located in a sub-subfolder.

On a test server I have onwcloud installed in a sub-sub-folder. The URL is http://test/schiesbn/owncloud If I generate a public link on the server I can open it just fine in the browser. But If I try to mount it, then sometimes I get a error message that the public link couldn't be mounted and sometimes it just continues. But after the next page reload I will get an empty files list. In the error log of the test server I see:

[Wed May 21 12:00:31 2014] [error] [client 192.168.1.24] script '/var/www/schiesbn/public.php' not found or unable to stat

As you can see that's the wrong path, the correct path is '/var/www/schiesbn/owncloud/public.php

I don't think it is a general routing problem, because open the public link with the browser works just fine. Maybe something wrong with the URL handling in the code handling the mount?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a minor issues, but it seems like we have some inconsistency regarding the namespace at the moment.
For example there is still \OC\Files\Storage\Shared and the server-to-server share is named OCA\Files_Sharing\External\Storage Would be good to unify it.

@schiessle

Copy link
Copy Markdown
Contributor

I moved now the owncloud folder up on the server so that the url is simply "test/owncloud.schiesbn", the error that he can't find public.php is gone but then I got in owncloud.log:

{"app":"PHP","message":"Undefined index: service at \/home\/schiesbn\/src\/owncloud\/public.php#12","level":3,"time":"2014-05-21T10:37:52+00:00"}

The code in public.php:

    if (!$pathInfo && !isset($_GET['service'])) {
        header('HTTP/1.0 404 Not Found');
        exit;
    } elseif ($_GET['service']) {
        $service = $_GET['service'];
    } else {
        $pathInfo = trim($pathInfo, '/');
        list($service) = explode('/', $pathInfo);
    }

I think it is quite obvious what's going on here. If 'service' isn't set but $pathinfo exists we will go to the elseif which of course will fail. Still strange that this only happens if I share the file from a physically different server. To solve the issue locally I changed the elseif to } elseif (!empty($_GET['service'])) {. Now the folder seems to be mounted just fine but this file_exists() test fails: https://github.com/owncloud/core/pull/8399/files#diff-c463069c55f33934fa9d755dff8eb13cR30

@icewind1991 before I invest more time debugging it on my systems it would be good to know if you can reproduce this issue or if it just happens on my system.

Comment thread apps/files_sharing/appinfo/routes.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - can we please move to controller classes, which can be unit tested instead of these ajax files? THX

@schiessle

Copy link
Copy Markdown
Contributor
  • deleting the mount point should not be used to umount it because it will also copy the mount point to the trash bin, please add a separate umount/unshare action. Delete operations together with the hooks and proxies should only be triggered if it is a real delete

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 52 new issues, 61 updated code elements

@ghost

ghost commented Jun 17, 2014

Copy link
Copy Markdown

@icewind1991

Copy link
Copy Markdown
Contributor Author

BUG: sync client cannot move files from mount into a subdir of mount (403 forbidden).

This leads to the question if "allow public upload" means that files inside the public share are editable

@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@icewind1991

Copy link
Copy Markdown
Contributor Author

@PVince81 major code issues are addressed.

@PVince81

Copy link
Copy Markdown
Contributor

BUG: sync client cannot move files from mount into a subdir of mount (403 forbidden).

This leads to the question if "allow public upload" means that files inside the public share are editable

Not really, this already works in the Web UI.

@ghost

ghost commented Jun 17, 2014

Copy link
Copy Markdown

@PVince81

Copy link
Copy Markdown
Contributor

Deleting shared storage works correctly now.
Code changes look good.

👍

@PVince81 PVince81 changed the title [WIP] Add server<->server sharing Add server<->server sharing Jun 17, 2014
@PVince81

Copy link
Copy Markdown
Contributor

This needs another thumbs up @LukasReschke

@schiesbn please review @icewind1991 's commits
@icewind1991 please review @schiesbn 's commits

Might do as well 😄

@icewind1991

Copy link
Copy Markdown
Contributor Author

👍 from my part to @MorrisJobke's and @schiesbn's changes

@schiessle

Copy link
Copy Markdown
Contributor

Did a quick test with encryption, looks good!

Let's merge it now, small issues can still be fixed afterwards.

👍

icewind1991 added a commit that referenced this pull request Jun 17, 2014
@icewind1991
icewind1991 merged commit 8d1cf79 into master Jun 17, 2014
@karlitschek

Copy link
Copy Markdown
Contributor

Yay. Great guys.

@MorrisJobke
MorrisJobke deleted the server-server-sharing branch June 17, 2014 23:11
@PVince81

Copy link
Copy Markdown
Contributor

Separate issues have been raised for the remaining issues, here is a summary:

Please evaluate which ones are more important to fix.

@karlitschek

Copy link
Copy Markdown
Contributor

@icewind1991 Can you please look into this issues and see what can be fixed in the next few days? Some of them are really important.

MorrisJobke added a commit that referenced this pull request Jan 5, 2015
* ownCloud 7.0.0 is needed - version of merge of server <-> server
  sharing - #8399
* adjust error message
MorrisJobke added a commit that referenced this pull request Jan 5, 2015
* ownCloud 7.0.0 is needed - version of merge of server <-> server
  sharing - #8399
* adjust error message

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging something more detailed would be really helpful. cc @DeepDiver1975 @icewind1991

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - as discussed with @LukasReschke - pull request is welcome @icewind1991 maybe? THX

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server <-> server sharing

10 participants