Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if symbolic link on Samba share with python

Tags:

python

samba

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 ?

like image 650
Emmanuel Avatar asked Nov 01 '25 00:11

Emmanuel


1 Answers

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.

like image 139
INS Avatar answered Nov 02 '25 16:11

INS