libsmbclient and smb_opendir: problem with workgroup

Derrell.Lipman at Derrell.Lipman at
Sun Jun 13 02:00:35 GMT 2004

Andreas <andreas at> writes:

> I have a machine in the MYGROUP workgroup that is misbehaving:
> [andreas at pandora source]$ smbclient -L duckman -N
> session request to DUCKMAN failed (Call timed out: server did not respond after 20000 milliseconds)
> (...)
> It does exist:
> [andreas at pandora source]$ nmblookup duckman
> querying duckman on
> duckman<00>
> I don't have shell access to see what is wrong, but that is not the point.
> The problem is that this missbehaviour is causing network browsing to fail
> as a whole.
> On my client machine I have "workgroup=MYGROUP" and this causes
> smbc_opendir("smb://") to return -1. If, however, I use
> "workgroup=SOMEGARBAGE" (SOMEGARBAGE doesn't exist), then smbc_opendir()
> works. Now, as I understand it, the "smb://" url is supposed to be used to
> list all workgroups in the network, why should my own workgroup matter?  Or
> does this "search" need to have some workgroup, even if it is an
> non-existing one?

If the master browser of the first workgroup found has not been up and running
for at least 12 minutes (that's the master browser running for 12 minutes, not
the machine) then it's possible that the list of other workgroups and their
master browsers has not been acquired by the found master browser.  In that
case, your request to that master browser will indicate that there's nothing
to be seen.  IIRC, if you specify a workgroup, then that workgroup's master
browser will be given your request, whereas if you give SOMEGARBAGE as the
workgroup, it will discover workgroups and use the first one discovered, which
would explain why your request works in one case but not the other (although
if it happened to find the master browser for MYGROUP first and that master
browser doesn't have the other browse lists, it wouldn't work even though you
specified SOMEGARBAGE).

smbclient has not been modified to use the new feature that I added to
libsmbclient a number of months ago, which solves this problem.  The new
feature allows smbc_opendir("smb://?mb=.all") to look at all master browsers
that can be discovered, rather than only the first one found, in order to
discover all workgroups on the network.  For backwards compatibility,
smbc_opendir("smb://") operates as it always did, requesting the browse list
only from the first master browser found.  See the comment above the function
smbc_parse_path() in the 3.0 or CVS HEAD tree, for the complete URI syntax now
supported by smbc_opendir().  I haven't looked at the smbclient source code,
but the change to it to solve your problem might be as simple as changing
"smb://" to the new "smb://?mb=.all".

Note that all of this should apply only if the master browser for MYGROUP has
been running for less than 12 minutes.  If it's been running for longer than
that, then the browse lists "should" have already been exchanged among the
various master browsers (in which case you can ignore this entire message. :-)


More information about the samba-technical mailing list