libsmbclient: lp_load() and setting the order of interfaces

Derrell.Lipman at UnwiredUniverse.com Derrell.Lipman at UnwiredUniverse.com
Mon Nov 17 20:05:26 GMT 2003


David Wuertele <dave-gnus at bfnet.com> writes:

> My program contains the following code:
>
>     lp_load ("eth0.conf", True, False, False);
>     smbc_init(auth_fn, 0);
>     setup_logging("read-all-browse-lists", False);
>     dh = smbc_opendir(url);
>     while (dirptr = smbc_readdir( dh )) {
>       char newurl[MAX_BUFF_SIZE];
>       if (debug > 2) fprintf (stderr, "adding server %s\n", dirptr->name);
>       add_server (dirptr->name);
>     }
>     smbc_closedir(dh);
>
> This works great for enumerating servers known to the LMB on eth0.  My
> problem is that I want to run it again, like this:
>
>     lp_load ("eth1.conf", True, False, False);
>     smbc_init(auth_fn, 0);
>     setup_logging("read-all-browse-lists", False);
>     dh = smbc_opendir(url);
>     while (dirptr = smbc_readdir( dh )) {
>       char newurl[MAX_BUFF_SIZE];
>       if (debug > 2) fprintf (stderr, "adding server %s\n", dirptr->name);
>       add_server (dirptr->name);
>     }
>     smbc_closedir(dh);
>
> The only difference is that I'm loading eth1.conf instead of
> eth0.conf.  The purpose is to load the interface list with a different
> interface, so that smbc_opendir() uses a different interface to scan
> an LMB on a different subnet.
>
> The problem is that lp_load() only seems to work once:  the second
> time I run it, eth1.conf is not loaded, or at least the behavior of
> smbc_opendir() is as if eth1.conf had not been loaded.
>
> If I just want to change the interfaces that smbc_opendir() uses, is
> there a simple way to do it?

Samba, or at least in this reference, the samba library, maintains some
persistent state information in a file called gencache.tdb (maybe found in
/var/run/samba/gencache.tdb, /usr/local/samba/var/locks/gencache.tdb, or
someplace else distro-specific).  To be really sure that you're starting with
a clean slate, remove that file before running your second scan.  I'm not sure
where/if that file gets opened and closed.  If you run those two scans in the
same application without quiting, you may need to look around the source to
determine how to force gencache.tdb to be closed and remove and/or
reinitialized.

Derrell



More information about the samba-technical mailing list