Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get file list on DFS shared folder #194

Open
alisichkin opened this issue Feb 26, 2022 · 6 comments
Open

Can't get file list on DFS shared folder #194

alisichkin opened this issue Feb 26, 2022 · 6 comments

Comments

@alisichkin
Copy link

Hello!

Can't get file list on Cisco VPN (Cisco Any Connect 4.10) - for directory level more than two.
When I try to get file list using function listPath - I get an error: Failed to list ILI_APPL_WRITE on DFS: Unable to open directory

from smb.SMBConnection import SMBConnection

conn = SMBConnection(username="xxx", password="xxx", my_name="localMachine", remote_name="ClusterCO2DFS", domain="GKSM", use_ntlm_v2=True, sign_options=SMBConnection.SIGN_WHEN_SUPPORTED)
connected = conn.connect("172.16.4.160", 139)

if connected:
    try:
        files = conn.listPath("DFS", "/ILI_APPL_WRITE")
        for file in files:
            if not file.isDirectory:
                print(f"{file.filename}")
    finally:
        conn.close()

When I try to execute command <files = conn.listPath("DFS", "/")> - command runs successfully.
When I try to connect and get file list from remote computer without VPN - everything runs without error.

I get same error from Windows 7 (Python 3.8.8), Windows 10 (Python 3.10) and Debian 10 (Python 3.7.3)

Sincerely,
Alexander.

Exception has occurred: OperationFailure
Failed to list ILI_APPL_WRITE on DFS: Unable to open directory
==================== SMB Message 0 ====================
SMB Header:

Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0x00000000
Flags: 0x08
PID: 8304
MID: 3
TID: 0
Data: 46 bytes
b'09500000480026005c005c0043004c005500530054004500520043004f0032004400460053005c00440046005300'
SMB Data Packet (hex):

b'fe534d4240000000000000000300000008000000000000000300000000000000702000000000000081060038a60600002d523c15a94b0eeef45044b7765e298d09500000480026005c005c0043004c005500530054004500520043004f0032004400460053005c00440046005300'
==================== SMB Message 1 ====================
SMB Header:

Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0x00000000
Flags: 0x09
PID: 8304
MID: 3
TID: 1
Data: 16 bytes
b'100001003008000008000000a9001200'
SMB Data Packet (hex):

b'fe534d4240000000000000000300010009500000000000000300000000000000702000000100000081060038a6060000e70eb777cc9563e875389a47eb085117100001003008000008000000a9001200'
==================== SMB Message 2 ====================
SMB Header:

Command: 0x05 (SMB2_COM_CREATE)
Status: 0x00000000
Flags: 0x08
PID: 8304
MID: 4
TID: 1
Data: 176 bytes
b'395000000200000000000000000000000000000000000000890010000000000007000000010000000100000078001c00980000005800000049004c0049005f004100500050004c005f0057005200490054004500000000002800000010000400000018001000000044486e510000000000000000000000000000000000000000180000001000040000001800000000004d78416300000000000000001000040000001800000000005146696400000000'
SMB Data Packet (hex):

b'fe534d4240000000000000000500000008000000000000000400000000000000702000000100000081060038a6060000f467e58c1ad8e7ee100cd869dcbb6313395000000200000000000000000000000000000000000000890010000000000007000000010000000100000078001c00980000005800000049004c0049005f004100500050004c005f0057005200490054004500000000002800000010000400000018001000000044486e510000000000000000000000000000000000000000180000001000040000001800000000004d78416300000000000000001000040000001800000000005146696400000000'
==================== SMB Message 3 ====================
SMB Header:

Command: 0x05 (SMB2_COM_CREATE)
Status: 0xC0000257
Flags: 0x09
PID: 8304
MID: 4
TID: 1
Data: 9 bytes
b'095000000000000000'
SMB Data Packet (hex):

b'fe534d4240000000570200c00500010009500000000000000400000000000000702000000100000081060038a6060000e50d2463457b4890aff226484af85e34095000000000000000'
File "C:\Source\Python\amtSMB.py", line 13, in
files = conn.listPath("DFS", "/ILI_APPL_WRITE")

@miketeo
Copy link
Owner

miketeo commented Feb 27, 2022

@alisichkin Part of the path is mounted on DFS which is not supported by pysmb. Unfortunately, I don't have the time to work on DFS support due to my time commitments in work and family.

@alisichkin
Copy link
Author

alisichkin commented Feb 27, 2022

That is, the error is related to DFS - Distributed File System, not VPN, as I assumed ?
P.S.
Family is a sacred

@miketeo
Copy link
Owner

miketeo commented Feb 27, 2022

Without knowing how the VPN is being configured, I can't really say for sure.
But you are right to have doubts over it since your script is working when it does not communicate over the VPN.
Does the file transfer work if you try to access using Windows explorer over the VPN?

@alisichkin
Copy link
Author

alisichkin commented Feb 27, 2022

Unfortunately - I did not test the DFS share in the office. I'm working remotely - so I tested pysmb by connected between my computer and my laptop. I tried to use another python library - smbprotocol - which, as author said, support DFS. But get an error - STATUS_PATH_NOT_COVERED - it indicates that the portion of the DFS namespace accessed by the client is not contained in the DFS root target server.
P.S.

import smbclient

smbclient.register_session(server='ClusterCO2DFS', username='xxxxx', password='xxxx', auth_protocol='ntlm')
dir = smbclient.listdir(r"\\ClusterCO2DFS\DFS") #work
dir = smbclient.listdir(r"\\ClusterCO2DFS\DFS\<one more>") #error - NtStatus error returned 'STATUS_PATH_NOT_COVERED'
print(f"{dir}")

P.S.S.
I found many references to DFS in the pysmb library code - support_dfs/SMB_FLAGS2_DFS, etc.
Version 1.1.14, 2015-02-01 (Download)
Add support for DFS shares in listPath(). Thanks to humberry (github) for raising the issue and helping with the testing.

Perhaps just need to specify some parameter - what share is DFS ?

@alisichkin alisichkin changed the title Can't get file list on Cisco VPN Can't get file list on DFS shared folder Mar 4, 2022
@alisichkin
Copy link
Author

The error is related to DFS. I used another library - smbprotocol - its supports working with DFS.
I did my work using smbprotocol.

@romutchio
Copy link

romutchio commented Jun 20, 2022

@alisichkin Hi. Could you tell please how you fixed the problem with the DFS in smbprotocol, cause I also get STATUS_PATH_NOT_COVERED error. Maybe some code snippet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants