お世話になります。
pysmbを用いてubuntuからwindowsの共有フォルダの配下にアクセスしたいのですが、
共有フォルダまでしかアクセスできません。
デバッグ方法、アドバイス等ご教示いただけると幸いです。
環境
サーバー
ubuntu 18.01
python 3.7.1
pysmb 1.2.6
クライアント
Windows Server 2012R2
python
1import platform 2from smb.SMBConnection import SMBConnection 3 4user = "administrator" 5pwd = "password" 6hostname = "WINFS" 7domainname = "DOMAIN" 8ipadress = "ipaddress" 9target = "path/to/folder" 10 11conn = SMBConnection( 12 user, 13 pwd, 14 platform.uname().node, 15 hostname, 16 domainname, 17 is_direct_tcp=True 18 ) 19 20def conn_WINFS(): 21 conn.connect(ipaddress,445) 22 # ここで接続先との疎通は確認してます 23 print(conn.echo("echo success"))
目的のフォルダまでのアクセスについては次の通り記述しています。
まず、共有フォルダまでは接続できます。
items = conn.listPath('share', '') print([item.filename for item in items]) # echo success # ['.', '..', 'path']
しかしながら、ターゲットまでのパスを追加するとエラーになります。
items = conn.listPath('share', target) print([item.filename for item in items])
エラーメッセージは次の通りです。
echo success Traceback (most recent call last): File "/home/username/app/myspace/scripts/smbs.py", line 27, in <module> conn_coopfs1() File "/home/username/app/myspace/scripts/smbs.py", line 17, in conn_coopfs1 items = conn.listPath('share', 'target') File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/smb/SMBConnection.py", line 203, in listPath self._pollForNetBIOSPacket(timeout) File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/smb/SMBConnection.py", line 637, in _pollForNetBIOSPacket self.feedData(data) File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/nmb/base.py", line 54, in feedData self._processNMBSessionPacket(self.data_nmb) File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/nmb/base.py", line 75, in _processNMBSessionPacket self.onNMBSessionMessage(packet.flags, packet.data) File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/smb/base.py", line 144, in onNMBSessionMessage if self._updateState(self.smb_message): File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/smb/base.py", line 338, in _updateState_SMB2 req.callback(message, **req.kwargs) File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/smb/base.py", line 642, in createCB errback(OperationFailure('Failed to list %s on %s: Unable to open directory' % ( path, service_name ), messages_history)) File "/home/username/.pyenv/versions/3.7.1/lib/python3.7/site-packages/smb/SMBConnection.py", line 197, in eb raise failure smb.smb_structs.OperationFailure: Failed to list path/to/folder on share: Unable to open directory ==================== SMB Message 0 ==================== SMB Header: ----------- Command: 0x03 (SMB2_COM_TREE_CONNECT) Status: 0x00000000 Flags: 0x00 PID: 32643 MID: 4 TID: 0 Data: 40 bytes b'09000000480020005c005c0043004f004f0050002d004600530031005c0073006800610072006500' SMB Data Packet (hex): ---------------------- b'fe534d4240000000000000000300000000000000000000000400000000000000837f000000000000950a0078001c01000000000000000000000000000000000009000000480020005c005c0043004f004f0050002d004600530031005c0073006800610072006500' ==================== SMB Message 1 ==================== SMB Header: ----------- Command: 0x03 (SMB2_COM_TREE_CONNECT) Status: 0x00000000 Flags: 0x01 PID: 32643 MID: 4 TID: 1 Data: 16 bytes b'100001000300000008000000a9001200' SMB Data Packet (hex): ---------------------- b'fe534d4240000000000000000300010001000000000000000400000000000000837f000001000000950a0078001c010000000000000000000000000000000000100001000300000008000000a9001200' ==================== SMB Message 2 ==================== SMB Header: ----------- Command: 0x05 (SMB2_COM_CREATE) Status: 0x00000000 Flags: 0x00 PID: 32643 MID: 5 TID: 1 Data: 152 bytes b'39000000020000000000000000000000000000000000000089001000000000000700000001000000010000007800080080000000580000001f7554532c67e8902800000010000400000018001000000044486e510000000000000000000000000000000000000000180000001000040000001800000000004d78416300000000000000001000040000001800000000005146696400000000' SMB Data Packet (hex): ---------------------- b'fe534d4240000000000000000500000000000000000000000500000000000000837f000001000000950a0078001c01000000000000000000000000000000000039000000020000000000000000000000000000000000000089001000000000000700000001000000010000007800080080000000580000001f7554532c67e8902800000010000400000018001000000044486e510000000000000000000000000000000000000000180000001000040000001800000000004d78416300000000000000001000040000001800000000005146696400000000' ==================== SMB Message 3 ==================== SMB Header: ----------- Command: 0x05 (SMB2_COM_CREATE) Status: 0xC0000257 Flags: 0x01 PID: 32643 MID: 5 TID: 1 Data: 9 bytes b'090000000000000000' SMB Data Packet (hex): ---------------------- b'fe534d4240000000570200c00500010001000000000000000500000000000000837f000001000000950a0078001c010000000000000000000000000000000000090000000000000000'
以上です。
よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。