-
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
register_connection fails in some conditions when netname_id is set to the IP of the samba server #158
Comments
Hmm that's interesting, the
While I don't doubt that that this negotiate context is causing your issue, especially since commenting it out gets it working again, I'm not sure what the proper next steps should be. To me it looks like a bug on the Samba side where it's either processing this context in a particular way, or it's failing because it has a strict set of contexts that it can receive. If either of these scenarios is the case then the proper fix would be to have Samba update their code. Failure to do so will result in other client that send this context id (newer Windows hosts) failing to negotiate with that server. Unfortunately this would require some more investigation before coming to a final conclusion.
The reason why
In that particular case the failure was happening on the next phase of the connection. It was also reported before I added the netname context (October 2021) so it wouldn't be related. Unfortunately Thanks for the excellent investigation work, it's been very helpful trying to narrow down what the problem is. Is it possible to share some more information so I can hopefully replicate it on my end? I'm hoping to find out:
If I can install Samba at the same version you are on then hopefully I can replicate your problem and potentially track down the bug in the code somewhere. |
Ah, so you mean really recent! Yeah, I agree it's probably a hard solve. Could I suggest making these "optional" connection parameters optional by an argument to the As for the versions of the software involved:
Here's the relevant sections from my Dockerfile:
My smb.conf looks like:
The usermap.txt is:
Thanks for your response and attention! |
I cannot seem to replicate this on my end, either by using your exact image or my own custom setup. Both a request from a Windows Server 2022 image and also from my localhost to the docker image work just fine. I even set up a fake hostname alias to test out when the value is completely unrelated to the Samba container. Even when testing your setup of communication between the containers I found it still passed the negotiation step when an IP was in the netname context I honestly cannot imagine why my setup is working but yours fails. Are you sure your Samba host is the one that's returning an error and nothing else is responding? One thing I did note was your |
Hey, I apologize for the typo in the Unfortunately I threw away the image that was affected in favor of the patched container... when I remove the patch, it continues to work. I tried to re-create the conditions and bring in all the software from both apt and pip to see if it was something conflicting there, and I cannot get this to reproduce. All the versions look as they were when I grabbed the versions yesterday. I'm baffled and extraordinarily apologetic as I know these issues are already pretty hard to reproduce and troubleshoot. |
Glad to hear it's working again for you. I can't explain why it started working for you, looking at the changelog there have been some recent changes to the package but nothing that seems related or was in the last 2 or so days. Considering it's now working for you I'll close off the issue. If it does appear again I'm happy to reinvestigate to try and understand it a bit better.
That's all good, the information you've shared has been great and helps to make tracking down these issues. If anything it's yet another thing to keep in mind if I start seeing more reports around this and I now have something more to start with. |
I have a docker container that has both python3/smbprotocol and samba in it. I updated it recently (last update was back in June 2021) and the nature by which the connection sets up has broken.
I fire up 2 containers, one running my python script and the other running the samba service. The first container connects to the second by finding its IP from docker (using docker inspect) and this has worked up until now.
This is the minimal code to reproduce by running from the first container (which is not running the smbd service):
I ran this from the container that the samba smbd service is running in and it works fine:
The two docker containers are based on the same image, which means the smbprotocol version and python environment is identical between the two.
I did a packet capture and noticed that the
SMB2_NETNAME_NEGOTIATE_CONTEXT_ID
is being set to the server value passed toregister_connection
. When it's set to the IP address 192.168.80.9 the connection fails with that STATUS_INVALID_PARAMETER, but when it's set to 127.0.0.1 it succeeds. I used socat from the first container to forward localhost port 445 to the second container's IP and tried connecting to 127.0.0.1 again in the first container and it succeeded.So next, I did another packet capture this time using samba's own smbclient and noticed it doesn't set the SMB2_NETNAME_NEGOTIATE_CONTEXT_ID negotiation parameter at all... so I commented out the
netname_id
field from the_send_smb2_negotiate
method of connection.py (around line 1490) from theneg_req['negotiate_context_list']
list. This fixed my connection issues and I've added a hack to my Dockerfile to fix my situation temporarily:(I use both Ubuntu's Bionic and conda's python3 so I patch them both)
I noticed issue #89 is similar to this, but may not actually be (in that issue the authentication type was forced to ntlm which seemed to fix their connectivity issue).
The text was updated successfully, but these errors were encountered: