jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
316 stars 73 forks source link

SmbDirEntry.is_symlink() doesn't return True on symlinks #197

Closed Alexinio97 closed 1 year ago

Alexinio97 commented 1 year ago

Hi, I have a linux share which has one file and one symlink to it: lrwxrwxrwx 1 alex alex 12 Oct 27 10:50 linked_file.txt -> someFile.txt -rw-r--r-- 1 alex alex 6 Oct 27 10:10 someFile.txt

I'm iterating through that directory with scandir() and checking the type of entry and it seems that linked_file.txt is treated as a regular file because is_file returns true for it while is_symlink returns false. Did you encounter this behaviour, I'm not sure if this is related to the samba server, treating links as regular files as well.

I tried this scan with follow symlinks = no and yes in the smb.conf but is_symlink won't return True for that file.

adiroiban commented 1 year ago

Thanks for your report.

So your server is Samba? Do you know which version of Samba is in used for this test?

What value you have for "wide links" ?


But does Samba support FILE_ATTRIBUTE_REPARSE_POINT ?

I think that the whole symlink configuration in Samba, is only for backend Samba operation. Those options are not related to SMB reparse points.

Alexinio97 commented 1 year ago

Thanks for your response. I'm using Samba version 4.9.5-Debian.

I used both yes and no values for wide links and still the same result. I noticed that these methods work for windows.

I'm not sure if Samba supports FILE_ATTRIBUTE_REPARSE_POINT, need to look into that.

Alexinio97 commented 1 year ago

follow symlinks This option controls whether Samba will follow a symbolic link in the Unix operating system to the target or if it should return an error to the client user. If the option is set to yes, the target of the link will be interpreted as the file. If set to no, an error will be generated if the symbolic link is accessed.

Found this in their documentation. I don't think we can do anything about it, right?

adiroiban commented 1 year ago

I noticed that these methods work for windows.

As in: "I noticed that smbprotocol can detect symbolic links when interacting with a Windows Share" ?


I think most samba options are related to "backend" operations.

The way attributes are advertised/disclosed to SMB clients is kind of "frontend" operation.

Alexinio97 commented 1 year ago

Yes, I noticed what you mentioned there.

adiroiban commented 1 year ago

Well is the below is true, it means that smbprotocol can detect symbolic links / reparse / junction points.

"I noticed that smbprotocol can detect symbolic links when interacting with a Windows Share"

The conclusion is that smbprotocol works fine.

is just that Samba either don't support advertising symlinks as reporse/junction points or there is a missing configuration on your Samba server.

But so far, it doesn't look like an issue with smbprotocol

Alexinio97 commented 1 year ago

Yes, you are right, thank you for the support! I guess we can close this.

jborean93 commented 1 year ago

Thanks for going through the details. Can confirm smbprotocol is reliant on the SMB server to share the link metadata for it to be seen as a symlink. Symlinks over SMB are special as they are resolved on the client side and not the server side that Samba does for symlinks internally.