"net -d 10" does not work anymore

Andrew Bartlett abartlet at samba.org
Sun Nov 21 03:14:51 MST 2010

On Sun, 2010-11-21 at 11:24 +1100, tridge at samba.org wrote:
> Hi Volker,
> I supect the problem is this line:
> 	lp_set_cmdline("log level", "0");
> in lib/netapi/netapi.c, line 76.
> Andrew, I think the AllowDebugChange code that was replaced with
> lp_set_cmdline() in cf4de8ec2c8df2ceabbe3d836d296b058e7b19fb didn't
> have exactly the same effect. 


Thanks for looking into this so carefully on your weekend.  I've now
spent quite some time looking over the interactions here, and I think
I've figured it out...

That certainly is a puzzle - on first glace the previous code here
seemed to quite clearly reset the debug level, but instead Gunther's
commit 77a25318105d90ae34a05c8a1e71df84343bb28e in 2008 created (as far
as I read the interactions) quite an odd situation, where we only set
DEBUGLEVEL to 0 if it was already 0! 

Of course, this is before the smb.conf is parsed, and the default is 0,
and the smb.conf wasn't allowed to reset it.

> The problem is that the parsing of -d on the command line uses the
> same lp_set_cmdline() call. A 2nd lp_set_cmdline() when libnet is
> initialised overrides a previous call, whereas with the old code the
> command line set had a higher precedence, so if the command line was
> parsed before the AllowDebugChange code was run, then the command line
> debug level was still used.

I'm not sure AllowDebugChange came into it, as it was a direct
assignment.  What AllowDebugChange did was stop the smb.conf load from
changing it again.

> The simplest fix is to just remove that line from netapi.c (patch
> below). At net.c:836 we've already set the default debug level
> correctly for the net tool, and the libnet API really has no reason
> for overriding that.

We can't do that, as the direct API callers will be expecting the debug
level to be set to 0, so that they are not swamped with level 10 logs,
even if the smb.conf calls for it.  (This is a public API)

I've instead split up libnetapi_init() into two functions, allowing
'net' to handle the loading of smb.conf and setting up the debug level,
without it being re-set inside libnetapi.  I've tested this a little,
but will look into this properly tomorrow.  


Attached is what I've worked out so far, please let me know if it
helps, and what you think. 

Andrew Bartlett

Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org
Samba Developer, Cisco Inc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-s3-netapi-Add-libnetapi_net_init-don-t-double-init-c.patch
Type: text/x-patch
Size: 8609 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20101121/fc9d7e50/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20101121/fc9d7e50/attachment.pgp>

More information about the samba-technical mailing list