hardcoded port 445

Christopher R. Hertel crh at ubiqx.mn.org
Mon Oct 31 15:36:19 MDT 2011

Andrew Bartlett wrote:
> On Mon, 2011-10-31 at 15:11 -0500, Christopher R. Hertel wrote:
>> Oskar Liljeblad wrote:
>>> Hi!
>>> I will be using Samba4 to operate in client mode.  The tunneling is simple,
>>> set up with ssh.  E.g.:
>> Samba is not a client, it is a server.  The Samba project provides a client
>> library called libsmbclient.  Is that what you what you will be using?
> Chris,
> Oskar is using the Samba4 DCE/RPC client library (as used by
> OpenChange).

Cool.  That's the piece of information I was missing.  Thanks!

Looking at the code snippets that Oskar sent in his original message, in
both cases the code uses the remote port number to decide whether or not to
send an NBT Session Request message.

That is, in fact, the correct approach.  If the remote port is 445, then it
is reasonable to assume that NBT transport is NOT in use.  If the port is
139, then it would be reasonable to assume that NBT transport IS in use.
For any other port number you have to guess, and sending the NBT Session
Request is as good a guess as any.

Samba servers do not care whether or not they receive the NBT Session
Request, no matter what port it is using.  Windows is more picky.

According to my book (http://ubiqx.org/cifs/SMB.html#SMB.3.3.1 ... now
somewhat out of date), if you try naked transport first and the Windows
server expects NBT transport it will return a Negative Session Response.
That is typically quick to handle.

Unfortunately, if you send an NBT Session Request to a Windows server that
is expecting Naked TCP transport, it will send no reply at all (tested
against W2K, see http://ubiqx.org/cifs/SMB.html#SMB.3.3.2, last paragraph).

So...  Once again, I agree with the logic in the code segment that Oskar
originally sent, as long as the code checks for a Negative Session Response
and tries again.

Chris -)-----

"Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/     -)-----   crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/    -)-----   crh at ubiqx.org

More information about the samba-technical mailing list