"net -d 10" does not work anymore

tridge at samba.org tridge at samba.org
Sat Nov 20 17:24:47 MST 2010


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. 

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.

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.

It might be worth making sure that all the other calls to force the
log level with lp_set_cmdline() are OK as well. The rule should be
that this call only happens before we've done command line
parsing. For example, the one in split_tokens.c looks wrong to me, and
the calls to libnetapi_set_debuglevel() also look like they might be a
problem.

Cheers, Tridge

--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -73,8 +73,6 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
                return W_ERROR_V(WERR_NOMEM);
        }
 
-       lp_set_cmdline("log level", "0");
-
        /* prevent setup_logging() from closing x_stderr... */
        setup_logging("libnetapi", DEBUG_STDERR);


More information about the samba-technical mailing list