catharsis / spotifile

FUSE file system for Spotify
BSD 3-Clause "New" or "Revised" License
149 stars 7 forks source link

Problems accessing mount via samba #51

Open discordianfish opened 8 years ago

discordianfish commented 8 years ago

Hi,

I've tried to run spotifile + samba and access the files from windows. Is there anything special samba might be doing which fails on spotifile? I've ran spotifile like this:

spotifile -d -o allow_root,default_permissions,umask=022

After setting up my credentials and mountpoint (/pub) in .config/spotifile/spotifile.conf.

The mountpoint and file permissions look good and I can read files as root as well as other users.

But finally when trying to access it with windows, spotifile prints:

unique: 680, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 30225
getattr /
   unique: 680, success, outsize: 120

And windows says the location is 'unavailable'.

My samba config section looks like this:

[pub]
   path = /pub
   guest ok = yes
   read only = yes

I've also tried to use something in /pub as mountpoint for spotifile but in that case windows just shows a empty file instead of a directory.. But that might be just that samba doesn't support spanning mount points dunno..

So any pointers welcome. I know this is a obscure setup. The only reason is that I want to play my spotify playlists in audioshield. This is what brought me to spotifile in the first place: https://www.reddit.com/r/Vive/comments/4hdjo4/any_way_to_play_spotify_library_in_audioshield/d2pcrcj

catharsis commented 8 years ago

Thanks for the report! That's a cool use-case that I never imagined :-)

Firstly, I must admit that my samba know-how is pretty limited (I've used it once or twice, perhaps) and I don't really have access to a Windows host to test things out on right now.

That said, is the getattr call really all you're getting? I suppose it's possible that samba has a different MO when it comes to accessing files, but it's strange that it's saying "success" and nothing else. I'd have to do some research on this.

Just to reduce the possible culprits: Have you tried accessing the mount from a non-Windows host? If not, could you try that and see if the behaviour differs?

catharsis commented 8 years ago

@discordianfish Just a shot in the dark here (you've probably already tried this), but search engineering suggests that adding the allow_other mount option might help.

discordianfish commented 8 years ago

@catharsis Right, sorry - I actually used allow_other after using allow_root first and was getting permission denied issues (which is weird again since smb runs as root but well). I'll try to find some time to debug this further. Also surprised there is just this getattr call.

discordianfish commented 8 years ago

Ok, I've tried it now with smbclient where I can connect and list files but get an error 'in dskattr':

$ smbclient -U "%" '\\XPS\pub'
WARNING: The "syslog" option is deprecated
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.9-Ubuntu]
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
smb: \> ls
  .                                            0  Wed Jun 22 12:36:06 2016
  ..                                  D        0  Tue Jun 21 20:01:10 2016
  connection                                   0  Wed Jun 22 12:36:06 2016
  browse                                       0  Wed Jun 22 12:36:06 2016
  search                                       0  Wed Jun 22 12:36:06 2016
  playlists                                    0  Wed Jun 22 12:36:06 2016
Error in dskattr: NT_STATUS_ACCESS_DENIED

It seems though as if it would consider all directories to be files. I can cd into those:

smb: \> cd playlists
cd \playlists\: not a directory
smb: \> stat playlists
File: \playlists
Size: 0             Blocks: 0   directory
Inode: 240518168581 Links: 0
Access: (0755/drwxr-xr-x)   Uid: 1000   Gid: 0
Access: 2016-06-22 12:36:06 +0200
Modify: 2016-06-22 12:36:06 +0200
Change: 2016-06-22 12:36:06 +0200

spotifile prints for the init connect:

unique: 58, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 8808
getattr /
   unique: 58, success, outsize: 120
unique: 59, opcode: STATFS (17), nodeid: 1, insize: 40, pid: 8808
statfs /
[W @ 2016-06-22 12:38:56 CEST] spotifile: Unimplemented function spfs_statfs called!
   unique: 59, error: -13 (Permission denied), outsize: 16

I don't know why this didn't show when trying to access from windows. I can only suspect it somehow 'cached' those issues. Anyways, I've returned 0 instead of -EACCES in spfs_statfs and now I don't get any errors when using smbclient, but the directories are still shown as files and I can't cd into them.

When trying to access from windows, I still get this error:

error

And spotifile says:

unique: 210, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 9557
getattr /
   unique: 210, success, outsize: 120
unique: 211, opcode: LOOKUP (1), nodeid: 1, insize: 52, pid: 9557
LOOKUP /desktop.ini
getattr /desktop.ini
   unique: 211, error: -2 (No such file or directory), outsize: 16
unique: 212, opcode: LOOKUP (1), nodeid: 1, insize: 52, pid: 9557
LOOKUP /desktop.ini
getattr /desktop.ini
   unique: 212, error: -2 (No such file or directory), outsize: 16
unique: 213, opcode: OPENDIR (27), nodeid: 1, insize: 48, pid: 9557
opendir flags: 0x18800 /
   opendir[139838296689424] flags: 0x18800 /
   unique: 213, success, outsize: 32
unique: 214, opcode: READDIR (28), nodeid: 1, insize: 80, pid: 9557
readdir[139838296689424] from 0
[D @ 2016-06-22 12:53:21 CEST] spotifile: filling existing dir (null) 
   unique: 214, success, outsize: 224
unique: 215, opcode: READDIR (28), nodeid: 1, insize: 80, pid: 9557
   unique: 215, success, outsize: 16
unique: 216, opcode: RELEASEDIR (29), nodeid: 1, insize: 64, pid: 0
releasedir[139838296689424] flags: 0x0
   unique: 216, success, outsize: 16
unique: 217, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 9557
getattr /
   unique: 217, success, outsize: 120
unique: 218, opcode: LOOKUP (1), nodeid: 1, insize: 52, pid: 9557
LOOKUP /desktop.ini
getattr /desktop.ini
   unique: 218, error: -2 (No such file or directory), outsize: 16
unique: 219, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 9557
getattr /
   unique: 219, success, outsize: 120

When trying thunar (uses gvfs) to access the samba share it appears as if it tries to open the whole mount point as file. When selecting it, it prints following error:

(thunar:9686): thunarx-CRITICAL **: thunarx_menu_provider_get_folder_actions: assertion 'thunarx_file_info_is_directory (folder)' failed

So my guess is that something in fuse and/or spotifile causes samba to assume all directories are files which breaks the samba clients..

discordianfish commented 8 years ago

Oh and samba itself doesn't throw any errors (beside some unrelated printer stuff).

catharsis commented 8 years ago

On my phone now, but this line sticks out:

[D @ 2016-06-22 12:53:21 CEST] spotifile: filling existing dir (null) 

That looks like a bug to me. If you're digging in the code, that might be a good place to look. An existing directory should reasonably never be null, unless I'm forgetting some peculiarity of the implementation.

catharsis commented 8 years ago

Scratch that, while it (the log line) is a bug, it is fairly inconsequential. Your problem is probably caused by something else. Let me know if you find anything else.

catharsis commented 8 years ago

@discordianfish Just a thought: Perhaps you could try to set st_mode to something more permissive in https://github.com/catharsis/spotifile/blob/master/src/spfs_fuse_entity.c#L106 ?

discordianfish commented 8 years ago

But the permissions look right and I don't get any permission errors.. No experience with fuse unfortunately but I'll keep digging. Something is making the files not appear as directory but only via samba.. hrm

catharsis commented 8 years ago

Yeah, pretty much a shot in the dark. I was just thinking that something is preventing samba from recognising the directories as such. I can't find the relevant logic in the Thunar source right now, but I have a feeling that if we found that we could fairly easily figure out where the problem lies.