Check if symbolic link on Samba share with python

2020-04-13 17:55发布

问题:

Can I know with Python from Windows if some files that I have access to on a Samba share are "real" files or symbolic links ? I tried os.path.islink but it returns false as the documentation states:

Always False if symbolic links are not supported

Is there any other way ?

回答1:

I used pysmb to access samba shares from python and I found that according to the MS documentation the (symbolic) link was not taken into account in the protocol specification.

I also tested with smbclient under Linux (Ubuntu) and there is no difference between links and directory.

So this seems to be a limitation of the samba specification.

PS: A project of mine aims to scan recursively a directory structure (samba share), which can loop forever in case of a symbolic link, since I cannot determine if it's a real directory or symbolic link.



标签: python samba