[jcifs] Server resolution for Windows 98

Christopher R. Hertel crh at ubiqx.mn.org
Sun Nov 10 18:55:50 EST 2002


Matthew Tippett wrote:
> 
> Hello,
> 
> I seem to have found (and fixed) a problem with the fallback from the
> *SMBSERVER called name not present condition when connecto to a master
> browser to retrieve a list of known domains.
> 
> The problem manifested itself when attempting to talk to windows 98 SE
> systems.  It looks like *SMBSERVER as a name is present in the CIFS
> standard, and is implemented in XP/NT and above, but not Win98.

Um... It's not a "name" per. se.  It's just that it is a permitted CALLED
NAME in the NBT Session Request.  Windows is picky about the CALLED NAME
field (Samba is not).  So, if you are talking to Windows NT4, XP, 2k, or to
Samba, you can use the "*SMBSERVER" name as the called name.  This is very
useful if the user handed you a DNS name or IP address instead of a NetBIOS
name.

> The
> Nautilus implementation of smb (most likely though libsmb has similar
> behaviour except it does a NBSTAT of
> *<00><00><00><00><00><00><00><00><00><00><00><00><00><00><00> vs the
> *<00> that jcifs currently does.

The correct wildcard name is 

  *<00><00><00><00><00><00><00><00><00><00><00><00><00><00><00>

...which translates to:

  CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

In testing, I found that Samba didn't care.  Samba does the extra work of
translating NBT name strings back into their original text format before
comparing them.  Samba also trims spaces, and if it finds a nul byte it
deals with it as a string terminator.  That in mind, the original names:

  "*\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  "*               "
  "*\0fooberrypie"

Would all be read by Samba (after encoding, sending over the wire, and
decoding) as the same thing: "*".

On the other hand, all of the Windows systems I've tested do *not* translate
the NBT name strings back to their original form before comparison.  So
Windows is looking for "CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".
That's a speed hack, but it does mean that Windows is pickier.

> By applying the patch attached, I can now connect to a windows 98 master
> browser and it all works great :).

I would say your patch is correct.  If it's faster (and simpler) to define
it as an array of bytes in encoded form then doing so might make sense. 
I'll let Mike answer that one.  From a theoretical point of view, there's no
need to translate it more than once.

> Chris or Michael, can you make a comment on the 'correctness' of doing
> this?

Captain Pedantic -)-----

> Matt
> --
> Matthew Tippett - matthew.tippett at sympatico.ca - (416) 435-4118
> Technology Forum - http://www.technology-forum.org/
> Commercial Open Source - http://www.commercialos.org/
> 
>   ----------------------------------------------------------------------------
> --- NbtAddress.java.orig        2002-11-04 02:27:37.000000000 -0500
> +++ NbtAddress.java     2002-11-10 02:08:29.000000000 -0500
> @@ -83,7 +83,7 @@
>   * on a network querying a workgroup group name is the preferred method.
>   */
> 
> -    static final String ANY_HOSTS_NAME = "*              ";
> +    static final String ANY_HOSTS_NAME = "*\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000";
> 
>  /**
>   * This is a special name for querying the master browser that serves the

-- 
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 jcifs mailing list