-
Notifications
You must be signed in to change notification settings - Fork 76
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
smbprotocol.exceptions.InvalidParameter from ubuntu to synology nas #199
Comments
Hmm based on your output the error is failing on the first message being sent, the SMB2 Negotiate Request. This might indicate that we are sending a value that the NAS is unable to parse but without having the box to test with it's hard for me to tell. Can you try the following and let me know what ones pass and which ones fail? import traceback
import uuid
from smbprotocol import Dialects
from smbprotocol.connection import Connection
for dialect in [Dialects.SMB_3_1_1, Dialects.SMB_3_0_2, Dialects.SMB_2_1_0]:
conn = Connection(uuid.uuid4(), "server2022.domain.test", 445)
try:
conn.connect(dialect=dialect)
except Exception as e:
print(f"Dialect 0x{dialect:04X} failed")
traceback.print_exc()
else:
conn.disconnect()
print(f"Dialect 0x{dialect:04X} successful") If all but Dialect import traceback
import uuid
from smbprotocol import Dialects
from smbprotocol.connection import Connection, Ciphers, SigningAlgorithms
conn = Connection(uuid.uuid4(), "server2022.domain.test", 445)
try:
conn.connect(
dialect=Dialects.SMB_3_1_1,
preferred_encryption_algos=[Ciphers.AES_128_GCM, Ciphers.AES_128_CCM],
preferred_signing_algos=[SigningAlgorithms.AES_CMAC],
)
except Exception as e:
print("Failure")
traceback.print_exc()
else:
conn.disconnect()
print("Success") Another option is to enable debug logging for Samba on your Synology box to see if it gives more info as to why it rejected the negotiate request. Seeing if there are any updates available would be good. I believe in the past some older Samba versions rejected a message with the Finally you can use Wireshark to compare the first SMB request sent by smbprotocol vs something like Windows. If you can share the capture that would be great. Otherwise comparing the |
Hi! Thanks for your quick answer! I just tried your test code with the nas ip instead of server2022.domain.test and got a partial success: First test
Second test
I looked at the logging options on synology but it seems to be able to only log the file operations, not the connection process. I'll try to connect on windows and record it with wireshark, I'll update you once it's done |
I tested your first bit of code on windows and ubuntu, the python traceback is the same for booth (and same as the one in the first message so I didn't include it here). Windows
Test on ubuntu:
|
So at a guess I believe the issue is the same with #158 where the presence of the Unfortunately at this point in time I'm not sure what else I can do. This field is meant to be ignored by older hosts and if it isn't even newer Windows builds will be failing to connect to it. Your only real recurse is to figure out if you can update the Samba version used on the Synology box. |
Ok so I did delete the SMB cache on the synology and opened the root share again (on windows 10), and to my surprise they communicated fully in ipv6 instead of ipv4. The Server Message Block Protocol part has less fields, I'm not even sure which version of the smb protocol it is using.
The Nas is already using the latest version of DSM so there's no update I can do. I'll gladly open an issue to them, but I'm not really good with network stuff so I'm not sure what to tell them exactly. |
That’s the smb1 request which you can ignore. See the next smb negotiate request to see the smb2 details which compare to what smbprotocol sends. |
My bad, here's the correct one.
Also I just noticed it now, but the two test script you provided had this field which seems incomplete, couldn't that be the source of the smbprotocol.exceptions.InvalidParameter error?
|
Thanks for confirming that Windows is sending
It certainly could be it and most likely the cause. I'll have to play around with this and see if I can replicate it in Wireshark and figure out why it's happening. At a guess the padding calculation is wrong. |
Thanks for all the information, it's been very helpful in tracking down the problem. The PR #201 will fix the problem here. Ultimately the code was adding padding where it wasn't actually needed as the hostname used was a multiple of 8 bytes. If this is still a problem when upgrading to 1.10.0 please let me know and I'll open the issue again to look further into it. |
Thanks for all your quick replies and fixing the problem so quickly, I'll try it tomorrow and update you if it's working :) |
Just tested it and it is now working! Thanks a lot! |
Fantastic, thanks for confirming. |
I've been trying to connect to a smb share in python 3.10 from ubuntu 22.04 to my Synology NAS (DS218 on DSM 7.1.1-42962 Update 1) and I got this error with a simple test code:
I tried with a few variations in the path string, a raw string string, with and without the auth_protocol="ntlm" param, with no better success.
Full traceback
The SMB is configured on the NAS to accept SMB1, SMB2, SMB2 and Large MTU and SMB3, encryption is defined by the client.
Packages list on the venv
I looked at issues #89 and #112 but I couldn't find any fitting solution in them
The text was updated successfully, but these errors were encountered: