1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

s3-debug Remove 'AllowDebugChange' and use lp_set_cmdline() instead

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
This commit is contained in:
Andrew Bartlett
2010-10-29 15:06:36 +11:00
parent 9da4ace1d9
commit cf4de8ec2c
17 changed files with 16 additions and 75 deletions

View 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);

View 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

View 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)) {

View 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;

View 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;

View 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,

View 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();

View 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)) {

View 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);

View 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);

View 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;

View 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);

View 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);

View 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);

View 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 */

View 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");

View 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)) {