s3-debug Remove 'AllowDebugChange' and use lp_set_cmdline() instead
authorAndrew Bartlett <abartlet@samba.org>
Fri, 29 Oct 2010 04:06:36 +0000 (15:06 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 2 Nov 2010 04:36:04 +0000 (04:36 +0000)
By removing this global variable, the API between the two different
debug systems is made more similar.  Both s3 and s4 now have
lp_set_cmdline() which ensures that the smb.conf cannot overwrite
these the user-specified log level.

Andrew Bartlett

17 files changed:
nsswitch/wins.c
source3/client/client.c
source3/lib/debug.c
source3/lib/netapi/netapi.c
source3/lib/popt_common.c
source3/param/test_lp_load.c
source3/torture/masktest.c
source3/utils/dbwrap_tool.c
source3/utils/dbwrap_torture.c
source3/utils/net.c
source3/utils/nmblookup.c
source3/utils/sharesec.c
source3/utils/smbcacls.c
source3/utils/smbcquotas.c
source3/utils/smbpasswd.c
source3/utils/split_tokens.c
source3/utils/testparm.c

index b4bc788f841815865eebfb6560d561e9475011a0..aa02f32ce14cdf5cde35eae786540b665b14ce31 100644 (file)
@@ -94,8 +94,7 @@ static int wins_lookup_open_socket_in(void)
 static void nss_wins_init(void)
 {
        initialised = 1;
-       DEBUGLEVEL = 0;
-       AllowDebugChange = False;
+       lp_set_cmdline("log level", "0");
 
        TimeInit();
        setup_logging("nss_wins",False);
index a7c09cf6c52f8a770655bf786b8fc0b5e6090b91..2c02e318a55f0d4ee6d59edeecd4aad096af4e8d 100644 (file)
@@ -5047,7 +5047,7 @@ static int do_message_op(struct user_auth_info *a_info)
 
         /* set default debug level to 1 regardless of what smb.conf sets */
        setup_logging( "smbclient", DEBUG_DEFAULT_STDERR );
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
+       lp_set_cmdline("log level", "1");
 
        load_case_tables();
 
@@ -5190,12 +5190,6 @@ static int do_message_op(struct user_auth_info *a_info)
                                               poptGetArg(pc));
        }
 
-       /*
-        * Don't load debug level from smb.conf. It should be
-        * set by cmdline arg or remain default (0)
-        */
-       AllowDebugChange = false;
-
        /* save the workgroup...
 
           FIXME!! do we need to do this for other options as well
index 321b08e0996c4d32889ce9ed51561bc79081eed3..ea0aad2c90ee64c6e5afac8bb402675efeb09fe7 100644 (file)
@@ -89,7 +89,6 @@ static struct {
 static char *debugf = NULL;
 bool    debug_warn_unknown_class = True;
 bool    debug_auto_add_unknown_class = True;
-bool    AllowDebugChange = True;
 
 /*
    used to check if the user specified a
@@ -469,9 +468,6 @@ bool debug_parse_levels(const char *params_str)
        /* Just in case */
        debug_init();
 
-       if (AllowDebugChange == False)
-               return True;
-
        params = str_list_make_v3(talloc_tos(), params_str, NULL);
 
        if (debug_parse_params(params)) {
index 30042467430be1dd194ffc31dbdd627c224ed8cb..7b3ab321afff1b47c2606de352e7667e06902214 100644 (file)
@@ -23,8 +23,6 @@
 #include "secrets.h"
 #include "krb5_env.h"
 
-extern bool AllowDebugChange;
-
 struct libnetapi_ctx *stat_ctx = NULL;
 TALLOC_CTX *frame = NULL;
 static bool libnetapi_initialized = false;
@@ -75,15 +73,11 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
                return W_ERROR_V(WERR_NOMEM);
        }
 
-       if (!DEBUGLEVEL) {
-               DEBUGLEVEL = 0;
-       }
+       lp_set_cmdline("log level", "0");
 
        /* prevent setup_logging() from closing x_stderr... */
        setup_logging("libnetapi", DEBUG_STDERR);
 
-       AllowDebugChange = false;
-
        load_case_tables();
 
        if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, false)) {
@@ -92,8 +86,6 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
                return W_ERROR_V(WERR_GENERAL_FAILURE);
        }
 
-       AllowDebugChange = true;
-
        init_names();
        load_interfaces();
        reopen_logs();
@@ -185,9 +177,8 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
                                        const char *debuglevel)
 {
-       AllowDebugChange = true;
        ctx->debuglevel = talloc_strdup(ctx, debuglevel);
-       if (!debug_parse_levels(debuglevel)) {
+       if (!lp_set_cmdline("log level", debuglevel)) {
                return W_ERROR_V(WERR_GENERAL_FAILURE);
        }
        return NET_API_STATUS_SUCCESS;
index a332cde56610db0ee3e7260997919b5a02f663ca..32906432df4ddcdb9deff31b64018c15635224f0 100644 (file)
@@ -36,7 +36,6 @@
 
 enum {OPT_OPTION=1};
 
-extern bool AllowDebugChange;
 extern bool override_logfile;
 
 static void set_logfile(poptContext con, const char * arg)
@@ -107,8 +106,7 @@ static void popt_common_callback(poptContext con,
 
        case 'd':
                if (arg) {
-                       debug_parse_levels(arg);
-                       AllowDebugChange = False;
+                       lp_set_cmdline("log level", arg);
                }
                break;
 
index 94715b5a596125a2671d17356f33a9adf831869b..d5673587a059f4cce6131ff6da2e0b985489e50a 100644 (file)
@@ -20,8 +20,6 @@
 #include "includes.h"
 #include "popt_common.h"
 
-extern bool AllowDebugChange;
-
 int main(int argc, const char **argv)
 {
        const char *config_file = get_dyn_CONFIGFILE();
@@ -41,7 +39,7 @@ int main(int argc, const char **argv)
        TALLOC_CTX *frame = talloc_stackframe();
 
        load_case_tables();
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
+       lp_set_cmdline("log level", "0");
 
        pc = poptGetContext(NULL, argc, argv, long_options,
                            POPT_CONTEXT_KEEP_FIRST);
@@ -61,9 +59,6 @@ int main(int argc, const char **argv)
                count = atoi(count_str);
        }
 
-       /* Don't let the debuglevel be changed by smb.conf. */
-       AllowDebugChange = False;
-
        for (i=0; i < count; i++) {
                printf("call lp_load() #%d: ", i+1);
                if (!lp_load_with_registry_shares(config_file,
index b8bcb4ade0049dabb780b17d88c661bb1672cdb4..335bc4ca22357b094edf5a8201f35d42e589e8d1 100644 (file)
@@ -34,7 +34,6 @@ static int ignore_dot_errors = 0;
 
 extern char *optarg;
 extern int optind;
-extern bool AllowDebugChange;
 
 /* a test fn for LANMAN mask support */
 static int ms_fnmatch_lanman_core(const char *pattern, const char *string)
@@ -484,8 +483,7 @@ static void usage(void)
 
        setlinebuf(stdout);
 
-       DEBUGLEVEL = 0;
-       AllowDebugChange = False;
+       lp_set_cmdline("log level", "0");
 
        if (argc < 2 || argv[1][0] == '-') {
                usage();
index ef61ea9dbbf0e6f8210a67afc2d0cb5d01fe29d4..796bea938d4dc616f55128be628fc88060604e3e 100644 (file)
@@ -22,8 +22,6 @@
 #include "includes.h"
 #include "dbwrap.h"
 
-extern bool AllowDebugChange;
-
 typedef enum { OP_FETCH, OP_STORE, OP_DELETE, OP_ERASE, OP_LISTKEYS } dbwrap_op;
 
 typedef enum { TYPE_INT32, TYPE_UINT32 } dbwrap_type;
@@ -214,9 +212,8 @@ int main(int argc, const char **argv)
        int ret = 1;
 
        load_case_tables();
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
+       lp_set_cmdline("log level", "0");
        setup_logging(argv[0], DEBUG_STDERR);
-       AllowDebugChange = false;
        lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
 
        if ((argc < 3) || (argc > 6)) {
index 35d00734896154c71cd7caaac215e47955b581fe..abb17e8e2acd5bcccf01d91ac26fa14d5b2223ee 100644 (file)
@@ -33,8 +33,6 @@
 #include <time.h>
 #endif
 
-extern bool AllowDebugChange;
-
 #define DEFAULT_DB_NAME "transaction.tdb"
 
 static int timelimit = 10;
@@ -259,7 +257,7 @@ int main(int argc, const char *argv[])
        }
 
        setup_logging(argv[0], DEBUG_STDERR);
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
+       lp_set_cmdline("log level", "0");
 
        pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
 
@@ -280,7 +278,6 @@ int main(int argc, const char *argv[])
        }
 
        load_case_tables();
-       AllowDebugChange = false;
        lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
 
        ev_ctx = tevent_context_init(mem_ctx);
index 6993f9e52c45a7418b2c1fa28a997078f4007577..44119dc2c6f0b9f15c7778a5e003d592ee87a55b 100644 (file)
@@ -47,8 +47,6 @@
 #include "lib/netapi/netapi.h"
 #include "../libcli/security/security.h"
 
-extern bool AllowDebugChange;
-
 #ifdef WITH_FAKE_KASERVER
 #include "utils/net_afs.h"
 #endif
@@ -835,7 +833,7 @@ static struct functable net_func[] = {
 #endif
 
        /* set default debug level to 0 regardless of what smb.conf sets */
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
+       lp_set_cmdline("log level", "0");
        c->private_data = net_func;
 
        pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
@@ -874,11 +872,6 @@ static struct functable net_func[] = {
                }
        }
 
-       /*
-        * Don't load debug level from smb.conf. It should be
-        * set by cmdline arg or remain default (0)
-        */
-       AllowDebugChange = false;
        lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
 
        argv_new = (const char **)poptGetArgs(pc);
index d7e0cb23ced1957d740e93cca5d486d0d486cbcf..b63b0a38e53177f3e6570e4a6bf3b6d5a1509250 100644 (file)
@@ -22,8 +22,6 @@
 #include "includes.h"
 #include "popt_common.h"
 
-extern bool AllowDebugChange;
-
 static bool give_flags = false;
 static bool use_bcast = true;
 static bool got_bcast = false;
index ae959bafb5d3c9828971c8ebced5ca1b393021bf..7ed238cdd46173343186723bb4a33354cbd74852 100644 (file)
@@ -544,7 +544,7 @@ int main(int argc, const char *argv[])
 
        /* set default debug level to 1 regardless of what smb.conf sets */
        setup_logging( "sharesec", DEBUG_STDERR);
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
+       lp_set_cmdline("log level", "1");
 
        pc = poptGetContext("sharesec", argc, argv, long_options, 0);
 
index 5ccdae6d08f356af0affdb24157a0ba3c1e97ad6..4de24dc767c35613d807ca15935f5a01073ec2fb 100644 (file)
@@ -27,8 +27,6 @@
 #include "rpc_client/cli_lsarpc.h"
 #include "../libcli/security/security.h"
 
-extern bool AllowDebugChange;
-
 static int test_args;
 
 #define CREATE_ACCESS_READ READ_CONTROL_ACCESS
@@ -1204,8 +1202,7 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info,
 
        /* set default debug level to 1 regardless of what smb.conf sets */
        setup_logging( "smbcacls", DEBUG_STDERR);
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
-       AllowDebugChange = false;
+       lp_set_cmdline("log level", "1");
 
        setlinebuf(stdout);
 
index 9721bc0b47b5864571ff1d6264121f984478191b..980ba2b5c1ea711205a35b70b85b9e95652165e9 100644 (file)
@@ -465,7 +465,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
 
        /* set default debug level to 1 regardless of what smb.conf sets */
        setup_logging( "smbcquotas", DEBUG_STDERR);
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
+       lp_set_cmdline("log level", "1");
 
        setlinebuf(stdout);
 
index 0fc002ad8aa79de5cc1f836a7c9cbf5bf662df44..c530c78f41fffd76b8152109fa06359808a0af7d 100644 (file)
@@ -20,8 +20,6 @@
 #include "secrets.h"
 #include "../librpc/gen_ndr/samr.h"
 
-extern bool AllowDebugChange;
-
 /*
  * Next two lines needed for SunOS and don't
  * hurt anything else...
@@ -570,8 +568,6 @@ int main(int argc, char **argv)
        int local_flags = 0;
        int ret;
 
-       AllowDebugChange = False;
-
 #if defined(HAVE_SET_AUTH_PARAMETERS)
        set_auth_parameters(argc, argv);
 #endif /* HAVE_SET_AUTH_PARAMETERS */
index e07d03aded03033eb4e68d8e1abfa90054ed9764..5d4b5a9260fd8063ca17741c7bd4ace575a3db7b 100644 (file)
@@ -26,8 +26,6 @@
 #include "includes.h"
 #include "popt_common.h"
 
-extern bool AllowDebugChange;
-
 int main(int argc, const char *argv[])
 {
        const char *config_file = get_dyn_CONFIGFILE();
@@ -58,9 +56,8 @@ int main(int argc, const char *argv[])
                fprintf(stderr, "ERROR: missing sequence string\n");
                return 1;
        }
-
-       DEBUGLEVEL = 0;
-       AllowDebugChange = false;
+       
+       lp_set_cmdline("log level", "0");
 
        if (!lp_load(config_file,false,true,false,true)) {
                fprintf(stderr,"Error loading services.\n");
index 8b8a31ea40e5ed1ebe35027103f15a7c542a927d..b17d61b91458660ebd1857a75e420ddae18b3487 100644 (file)
@@ -34,8 +34,6 @@
 #include "includes.h"
 #include "popt_common.h"
 
-extern bool AllowDebugChange;
-
 /*******************************************************************
  Check if a directory exists.
 ********************************************************************/
@@ -352,7 +350,7 @@ rameter is ignored when using CUPS libraries.\n",
         * Allow it to be overridden by the command line,
         * not by smb.conf.
         */
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 2;
+       lp_set_cmdline("log level", "2");
 
        pc = poptGetContext(NULL, argc, argv, long_options, 
                            POPT_CONTEXT_KEEP_FIRST);
@@ -381,9 +379,6 @@ rameter is ignored when using CUPS libraries.\n",
                goto done;
        }
 
-       /* Don't let the debuglevel be changed by smb.conf. */
-       AllowDebugChange = False;
-
        fprintf(stderr,"Load smb config files from %s\n",config_file);
 
        if (!lp_load_with_registry_shares(config_file,False,True,False,True)) {