jborean93 / smbprotocol

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

`listdir` requires server name on its call #268

Closed GabrielDornelles closed 8 months ago

GabrielDornelles commented 8 months ago

Although the example says the methods can be used without explicitly passing server_name user and password after making the first op, listdir still requires it. Below there is the two examples (I ran a mkdir op before on both cases but left out as its not part of the issue).

Works:

from smbclient import listdir, register_session

register_session("192.168.1.1", username="admin", password="password")

for filename in listdir("192.168.1.1/shared"):
    print(filename)

Doesn't:

from smbclient import listdir, register_session

register_session("192.168.1.1", username="admin", password="password")

for filename in listdir("shared"):
    print(filename)

>>> ValueError: The SMB path specified must contain the server and share to connect to

I wonder if thats intentional as the valueerror suggests, but at documentation its not really clear.