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

smb:// File Get Not Working #69

Closed
McFateM opened this issue Apr 30, 2018 · 13 comments
Closed

smb:// File Get Not Working #69

McFateM opened this issue Apr 30, 2018 · 13 comments

Comments

@McFateM
Copy link
Contributor

McFateM commented Apr 30, 2018

I keep getting errors like the following in the latest code...

    HTTP error -1003 occurred when trying to fetch smb://132.161.10.13/LIBRARY/LIBSTU/AlumniOralHistories/Complete/ReadyForIMI/Douglas_Peterson_50/Doug_Peterson_50.MP3.
    HTTP error -1003 occurred when trying to fetch smb://132.161.10.13/LIBRARY/LIBSTU/AlumniOralHistories/Complete/ReadyForIMI/Douglas_Peterson_50/IOH-Peterson.xml.

I've tried many forms of these file specs but no matter what smb:// always returns errors like this even though 'smb' is in the list of valid request schemes. When debugging this I consistently see this code...

  $result = drupal_http_request($url);
  if ($result->code != 200) {
    drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
    return FALSE;
  }

...in system.module returning a code of 1003.

@DiegoPino
Copy link
Contributor

DiegoPino commented Apr 30, 2018 via email

@McFateM
Copy link
Contributor Author

McFateM commented Apr 30, 2018 via email

@DiegoPino
Copy link
Contributor

@McFateM did my homework and Drupal is to blame here (culprit!)
I based my code to discern what is local/remote on this

Happens that samba/NFS/ftp are routed to system_retrieve_file where finally drupal_http_request gets called BUT:
drupal_http_requestonly knows about http, https and feed. So all bad there. 1003 code means unknown schema.

Changes I need to make
handle anything not HTTP or HTTPS as possibly stream wrapper (instead of remote via drupal_http_blabla).
Then check if the given stream wrapper actually exists

print_r(stream_get_wrappers());


Array
(
    [0] => https
    [1] => ftps
    [2] => compress.zlib
    [3] => compress.bzip2
    [4] => php
    [5] => file
    [6] => glob
    [7] => data
    [8] => http
    [9] => ftp
    [10] => phar
    [11] => zip
    [12] => public
    [13] => temporary
)

Issue here is to enable smb:// or anything not standard we need to include a library and a unix client like this
https://github.com/munkie/samba
And that will make stuff way to complicated for other people to deploy.
The solution: make a new hook that can allow people to deploy other different stream wrappers.

I will make some changes tonight but i will need you to help me figure out where to add the hooks (register wrappers?) so they are available when fetching is needed. I will provide a demo submodule using this one https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-stream-wrapper.html
so other people can follow.

@McFateM
Copy link
Contributor Author

McFateM commented May 1, 2018

Thanks Diego. I did see the drupal_http_request() call in the code yesterday and wondered what kind of alternative would be necessary.

Personally, I'd just remove 'smb' from the list of acceptable schemes and we could rely on the hook I've provided to handle SMB requests. If you want to take that approach I'd be happy to try enhancing my hook implementation and provide an example to share. I've already made changes to that hook implementation to report the hook(s) that succeed or fail so that folks who implement the hook will have a better idea what it has done.

@McFateM
Copy link
Contributor Author

McFateM commented May 1, 2018

Update: Since my hook is not working in the new code I'd suggest a solution like the one you proposed above. I can certainly help with calling the hooks if you can create a sample one that works. Thanks.

@DiegoPino
Copy link
Contributor

Cool. Will keep this one open once i have the code working. Will need your testing of course.

@McFateM
Copy link
Contributor Author

McFateM commented May 3, 2018

Good morning @DiegoPino. Have you made any progress with SMB? I could really use it and started to try and implement in my hook this morning with https://github.com/icewind1991/SMB but immediately ran into an issue: that project requires PHP 5.6 or greater, and my target server is still running PHP 5.5.9. 8^(

For now I may focus instead on adding a "hook" option to the pull-down that provides download mechanisms, that way we need not burden the "*local" option with something that is obviously not "local".

@DiegoPino
Copy link
Contributor

DiegoPino commented May 3, 2018 via email

@McFateM
Copy link
Contributor Author

McFateM commented May 3, 2018

Yep, I was just thinking along those lines too. The other night I found some guidance about mounting the share as CIFS and accessing it that way. I might just give that a spin this morning in my hook implementation. Thanks. I'll keep you posted.

@petermacdonald
Copy link

I mount a windows SAN as a CIFS share on our CentOS box for purposes of Islandora ingest. If you want the code I'll send it to you or I'll ask Steve to do so.

Peter

@McFateM
Copy link
Contributor Author

McFateM commented May 4, 2018

No need, but thanks Peter. I've got my mount strategy worked out already. In fact, I am ingesting a few hundred new objects with it right now. My mount is from a Samba network share...

sudo mount -t cifs -o username=mcfatem //storage.grinnell.edu/LIBRARY/mcfatem/PHPP_Content /mnt/storage

@DiegoPino
Copy link
Contributor

@McFateM #70 merged. I would say we can close this one for now? I will test public:// and private// tomorrow to see if they actually resolve or not. Thanks a lot

@McFateM
Copy link
Contributor Author

McFateM commented May 8, 2018

Yes. Thanks for all your help and good work on IMI (and so much more).

@McFateM McFateM closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants