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

new SMB storage backend #4770

Closed
wants to merge 28 commits into from
Closed

new SMB storage backend #4770

wants to merge 28 commits into from

Conversation

icewind1991
Copy link
Contributor

New implementation of the SMB storage backend using a new wrapper for smbclient (https://github.com/icewind1991/SMB).
This improves the test-ability and maintainability of the SMB backend and hopefully helps with the various issues the current SMB backend has.

Tested it locally against an smb server running on arch, requires testing against a windows smb server.

cc @DeepDiver1975 @karlitschek

@ghost
Copy link

ghost commented Sep 8, 2013

Test failed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/939/

@ghost
Copy link

ghost commented Sep 8, 2013

Test passed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/941/

}

public function isUpdatable($path) {
return true;
Copy link
Member

Choose a reason for hiding this comment

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

hmm - smb/cifs shares can be read only as well

@DeepDiver1975
Copy link
Member

@icewind1991
Tested it against a Windows 7 machine
testRoot and testMimeType are failing
testFOpen and all remaining test could not be executed because a lot of smbclient processes (one for each executed test) consumed all the cpu - there is something wrong with the process termination of smbclient

Regarding testRoot:
it failes with root being '', '/', '/test and 'test'

for further testing: grab a windows vm here: http://www.modern.ie/en-US/virtualization-tools#downloads
Feel free ti catch me on irc in case you need help with the setup of shares in windows

@ghost
Copy link

ghost commented Sep 9, 2013

Test passed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/953/

@itn3rd77
Copy link
Contributor

@icewind1991 Did you keep in mind the issue #2502 when implementing the new SMB storage backend?

@DeepDiver1975
Copy link
Member

OC7

@PVince81
Copy link
Contributor

@icewind1991 I haven't read the code yet. Will it support streaming ? (ie not having to download a whole file when only the first MB is needed, for example for thumbnail generation or mimetype detection)

@icewind1991
Copy link
Contributor Author

No, that is a limitation of smbclient itself

@PVince81
Copy link
Contributor

Would be good to check whether it's possible to tell smbclient to output the file contents to stdout instead of a target file (or pipe it). If that works, it might be possible to stream whatever comes from its stdout back to ownCloud, maybe using popen() and pipes.

@PVince81
Copy link
Contributor

Awwwyeah, streaming/piping could work, this worked for me:

smbclient \\\\localhost\\shared -N -c "get pic.jpg -"

Seems it can work with put as well:

cat pic.jpg | smbclient \\\\localhost\\shared -N -c "put - pic.jpg"

}

public function isReadable($path) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to either use file_exists() or fallback to the default impl that does just that.
Same for isUpdatable().
Always returning true might make callers believe that a file exists when it doesn't (scanFile())

@icewind1991
Copy link
Contributor Author

Updated streamwrapper and storage.

tested against a windows 8 VM and a samba server on Arch Linux.

@scrutinizer-notifier
Copy link

A new inspection was created.

@ghost
Copy link

ghost commented Feb 25, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/3328/

@PVince81 PVince81 mentioned this pull request Mar 6, 2014
10 tasks

require_once 'errors.php';

spl_autoload_register(function ($class) {
Copy link

Choose a reason for hiding this comment

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

Can't this be done in a more automatic-autoload-approach, i.e. without registering your own autoloader?

@bantu
Copy link

bantu commented Mar 6, 2014

Please add class documentation to all classes. E.g. it should be easily possible to see what the difference between RawConnection and Connection is.

* $pipes[0] holds STDIN for smbclient
* $pipes[1] holds STDOUT for smbclient
*/
private $pipes;
Copy link

Choose a reason for hiding this comment

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

Shouldn't these be available to subclasses? Personally, I think that the number of proper use-cases of private is just as limited as the number of use-cases for static.

@bantu
Copy link

bantu commented Mar 6, 2014

A PHP Stream Wrapper for SMB would be pretty awesome. :-)

@PVince81
Copy link
Contributor

@icewind1991 I started testing this, see some failing results here #4770 (comment)

@PVince81
Copy link
Contributor

I'd say better rebase this first, it seems some issues might be caused by stuff that was fixed already on master.

@scrutinizer-notifier
Copy link

A new inspection was created.

@DeepDiver1975
Copy link
Member

Do we really want to continue with the approach to fork smbclient processes?

Even with a much better looking code base the basic mechanism remains - I'd prefer to have a native php module which uses samba libs to talk to smb/cifs shares directly.

@karlitschek @icewind1991 @PVince81

@bantu
Copy link

bantu commented Apr 7, 2014

@DeepDiver1975 I think improving the existing approach using smbclient via exec is an acceptable intermediate step.

@PVince81
Copy link
Contributor

PVince81 commented Apr 7, 2014

One advantage I saw here is that the smbclient process is only started once, and its internal CLI is driven by @icewind1991 's code which should improve performance a bit as we don't need to restart the process for every command (stat, etc...)

I'm still a bit afraid that this big change causes regressions.

@icewind1991
Copy link
Contributor Author

I agree that having a native php module would be the optimal solution but that wont be available in all situations

@ghost
Copy link

ghost commented Apr 7, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/4109/

@DeepDiver1975
Copy link
Member

that wont be available in all situations

true - but installations not capable of installing a custom/self-built php module generally don't need access to smb shares

* @return string
*/
public function read() {
return trim(fgets($this->pipes[1]));
Copy link

Choose a reason for hiding this comment

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

Hmm. trim() on binary data?

@icewind1991
Copy link
Contributor Author

superseded by #10673

@MorrisJobke MorrisJobke deleted the smb branch January 31, 2015 08:40
@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.

8 participants