summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2002-05-18 15:09:21 +0000
committerSimo Sorce <idra@samba.org>2002-05-18 15:09:21 +0000
commit2a02a76913a91c9882868b73c72ba2e8d2be764d (patch)
tree4f1f0bc22e790381cf655ea6ce592660db1f2d52
parentf9d2db36f36abc39a9a905a69b0f2e0182d0caca (diff)
downloadsamba-2a02a76913a91c9882868b73c72ba2e8d2be764d.tar.gz
samba-2a02a76913a91c9882868b73c72ba2e8d2be764d.tar.bz2
samba-2a02a76913a91c9882868b73c72ba2e8d2be764d.zip
so here it is the code to introduce seriously debugggging classes.
this is a first step only passdb stuff has beein "classized". - so what can you do? set debug level to: 1 poasdb:10 that will make all the code run at debug level 1 except the code in passdb/* files that will run at level 10 TODO: fix the man page - also smbcontrol has this nice feature so smbcontrol smbd debug 3 passdb:5 will set every smbd to have a default log level of 3 while passdb stuff will be at level 5 and so no.. minor cosmetic fix to pdbedit is there too (This used to be commit be5c3b3f5781ddc002ffcc98df04ab024dcef4ca)
-rw-r--r--source3/include/debug.h24
-rw-r--r--source3/lib/debug.c332
-rw-r--r--source3/lib/messages.c10
-rw-r--r--source3/param/loadparm.c5
-rw-r--r--source3/passdb/machine_sid.c2
-rw-r--r--source3/passdb/passdb.c3
-rw-r--r--source3/passdb/passgrp.c3
-rw-r--r--source3/passdb/pdb_get_set.c3
-rw-r--r--source3/passdb/pdb_interface.c3
-rw-r--r--source3/passdb/pdb_ldap.c3
-rw-r--r--source3/passdb/pdb_plugin.c3
-rw-r--r--source3/passdb/pdb_smbpasswd.c2
-rw-r--r--source3/passdb/pdb_tdb.c25
-rw-r--r--source3/passdb/secrets.c3
-rw-r--r--source3/utils/pdbedit.c3
-rw-r--r--source3/utils/smbcontrol.c46
16 files changed, 368 insertions, 102 deletions
diff --git a/source3/include/debug.h b/source3/include/debug.h
index 235fbf70c4..9cd7c7097d 100644
--- a/source3/include/debug.h
+++ b/source3/include/debug.h
@@ -38,8 +38,10 @@
*/
int Debug1( char *, ... ) PRINTF_ATTRIBUTE(1,2);
BOOL dbgtext( char *, ... ) PRINTF_ATTRIBUTE(1,2);
+BOOL dbghdr( int level, char *file, char *func, int line );
extern XFILE *dbf;
+extern pstring debugf;
/* If we have these macros, we can add additional info to the header. */
#ifdef HAVE_FILE_MACRO
@@ -64,7 +66,7 @@ extern XFILE *dbf;
* because some references would expand incorrectly.
*/
#define DEBUGLEVEL *debug_level
-
+extern int DEBUGLEVEL;
/*
* Define all new debug classes here. A class is represented by an entry in
@@ -77,7 +79,6 @@ extern XFILE *dbf;
* at the start of the file (after #include "includes.h") will default to
* using index zero, so it will behaive just like it always has.
*/
-#define DBGC_CLASS 0 /* override as shown above */
#define DBGC_ALL 0 /* index equivalent to DEBUGLEVEL */
#define DBGC_TDB 1
@@ -86,17 +87,18 @@ extern XFILE *dbf;
#define DBGC_SMB 4
#define DBGC_RPC 5
#define DBGC_RPC_HDR 6
-#define DBGC_BDC 7
+#define DBGC_PASSDB 7
+#define DBGC_AUTH 8
+#define DBGC_BDC 9
-#define DBGC_LAST 8 /* MUST be last class value + 1 */
-extern int DEBUGLEVEL_CLASS[DBGC_LAST];
-extern BOOL DEBUGLEVEL_CLASS_ISSET[DBGC_LAST];
+/* So you can define DBGC_CLASS before including debug.h */
+#ifndef DBGC_CLASS
+#define DBGC_CLASS 0 /* override as shown above */
+#endif
-struct debuglevel_message {
- int debuglevel_class[DBGC_LAST];
- BOOL debuglevel_class_isset[DBGC_LAST];
-};
+extern int *DEBUGLEVEL_CLASS;
+extern BOOL *DEBUGLEVEL_CLASS_ISSET;
/* Debugging macros
*
@@ -151,7 +153,7 @@ struct debuglevel_message {
#define DEBUGLVL( level ) \
( ((level) <= MAX_DEBUG_LEVEL) && \
((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
- (!DEBUGLEVEL_CLASS[ DBGC_CLASS ] && \
+ (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
&& dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 7960c32b58..0a4cee89ae 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -2,6 +2,8 @@
Unix SMB/CIFS implementation.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Elrond 2002
+ Copyright (C) Simo Sorce 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -81,11 +83,23 @@
XFILE *dbf = NULL;
pstring debugf = "";
BOOL append_log = False;
+BOOL debug_warn_unknown_class = True;
+BOOL debug_auto_add_unknown_class = True;
+BOOL AllowDebugChange = True;
-int DEBUGLEVEL_CLASS[DBGC_LAST];
-BOOL DEBUGLEVEL_CLASS_ISSET[DBGC_LAST];
-int DEBUGLEVEL = DEBUGLEVEL_CLASS;
-BOOL AllowDebugChange = True;
+/*
+ * This is to allow assignment to DEBUGLEVEL before the debug
+ * system has been initialised.
+ */
+static int debug_all_class_hack = 1;
+static BOOL debug_all_class_isset_hack = True;
+
+static int debug_num_classes = 0;
+int *DEBUGLEVEL_CLASS = &debug_all_class_hack;
+BOOL *DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack;
+
+/* DEBUGLEVEL is #defined to *debug_level */
+int DEBUGLEVEL = &debug_all_class_hack;
/* -------------------------------------------------------------------------- **
@@ -129,7 +143,7 @@ static BOOL log_overflow = False;
* white space. There must be one name for each DBGC_<class name>, and they
* must be in the table in the order of DBGC_<class name>..
*/
-char *classname_table[] = {
+static const char *default_classname_table[] = {
"all", /* DBGC_ALL; index refs traditional DEBUGLEVEL */
"tdb", /* DBGC_TDB */
"printdrivers", /* DBGC_PRINTDRIVERS */
@@ -137,32 +151,103 @@ char *classname_table[] = {
"smb", /* DBGC_SMB */
"rpc", /* DBGC_RPC */
"rpc_hdr", /* DBGC_RPC_HDR */
+ "passdb", /* DBGC_PASSDB */
+ "auth", /* DBGC_AUTH */
"bdc", /* DBGC_BDC */
+ NULL
};
+static char **classname_table = NULL;
+
/* -------------------------------------------------------------------------- **
* Functions...
*/
+
+/****************************************************************************
+utility lists registered debug class names's
+****************************************************************************/
+
+#define MAX_CLASS_NAME_SIZE 1024
+
+char *debug_list_class_names_and_levels()
+{
+ int i, dim;
+ char **list;
+ char *buf = NULL;
+ char *b;
+ BOOL err = False;
+
+ if (DEBUGLEVEL_CLASS == &debug_all_class_hack)
+ return NULL;
+
+ list = calloc(debug_num_classes + 1, sizeof(char *));
+ if (!list)
+ return NULL;
+
+ /* prepare strings */
+ for (i = 0, dim = 0; i < debug_num_classes; i++) {
+ int l = asprintf(&list[i],
+ "%s:%d ",
+ classname_table[i],
+ DEBUGLEVEL_CLASS_ISSET[i]?DEBUGLEVEL_CLASS[i]:DEBUGLEVEL);
+ if (l < 0 || l > MAX_CLASS_NAME_SIZE) {
+ err = True;
+ goto done;
+ }
+ dim += l;
+ }
+
+ /* create single string list */
+ b = buf = malloc(dim);
+ if (!buf) {
+ err = True;
+ goto done;
+ }
+ for (i = 0; i < debug_num_classes; i++) {
+ int l = strlen(list[i]);
+ strncpy(b, list[i], l);
+ b = b + l;
+ }
+ b[-1] = '\0';
+
+done:
+ /* free strings list */
+ for (i = 0; i < debug_num_classes; i++)
+ if (list[i]) free(list[i]);
+ free(list);
+
+ if (err) {
+ if (buf)
+ free(buf);
+ return NULL;
+ } else {
+ return buf;
+ }
+}
+
/****************************************************************************
utility access to debug class names's
****************************************************************************/
-char* debug_classname_from_index(int ndx)
+const char *debug_classname_from_index(int ndx)
{
- return classname_table[ndx];
+ if (ndx < 0 || ndx >= debug_num_classes)
+ return NULL;
+ else
+ return classname_table[ndx];
}
/****************************************************************************
-utility to translate names to debug class index's
+utility to translate names to debug class index's (internal version)
****************************************************************************/
-int debug_lookup_classname(char* classname)
+static int debug_lookup_classname_int(const char* classname)
{
int i;
if (!classname) return -1;
- for (i=0; i<DBGC_LAST; i++) {
+ for (i=0; i < debug_num_classes; i++) {
if (strcmp(classname, classname_table[i])==0)
return i;
}
@@ -170,6 +255,118 @@ int debug_lookup_classname(char* classname)
}
/****************************************************************************
+Add a new debug class to the system
+****************************************************************************/
+int debug_add_class(const char *classname)
+{
+ int ndx;
+ void *new_ptr;
+
+ if (!classname)
+ return -1;
+
+ /* check the init has yet been called */
+ debug_init();
+
+ ndx = debug_lookup_classname_int(classname);
+ if (ndx >= 0)
+ return ndx;
+ ndx = debug_num_classes;
+
+ new_ptr = DEBUGLEVEL_CLASS;
+ if (DEBUGLEVEL_CLASS == &debug_all_class_hack)
+ {
+ /* Initial loading... */
+ new_ptr = NULL;
+ }
+ new_ptr = Realloc(new_ptr,
+ sizeof(int) * (debug_num_classes + 1));
+ if (!new_ptr)
+ return -1;
+ DEBUGLEVEL_CLASS = new_ptr;
+ DEBUGLEVEL_CLASS[ndx] = 0;
+
+ /* debug_level is the pointer used for the DEBUGLEVEL-thingy */
+ if (ndx==0)
+ {
+ /* Transfer the initial level from debug_all_class_hack */
+ DEBUGLEVEL_CLASS[ndx] = DEBUGLEVEL;
+ }
+ debug_level = DEBUGLEVEL_CLASS;
+
+ new_ptr = DEBUGLEVEL_CLASS_ISSET;
+ if (new_ptr == &debug_all_class_isset_hack)
+ {
+ new_ptr = NULL;
+ }
+ new_ptr = Realloc(new_ptr,
+ sizeof(BOOL) * (debug_num_classes + 1));
+ if (!new_ptr)
+ return -1;
+ DEBUGLEVEL_CLASS_ISSET = new_ptr;
+ DEBUGLEVEL_CLASS_ISSET[ndx] = False;
+
+ new_ptr = Realloc(classname_table,
+ sizeof(char *) * (debug_num_classes + 1));
+ if (!new_ptr)
+ return -1;
+ classname_table = new_ptr;
+
+ classname_table[ndx] = strdup(classname);
+ if (! classname_table[ndx])
+ return -1;
+
+ debug_num_classes++;
+
+ return ndx;
+}
+
+/****************************************************************************
+utility to translate names to debug class index's (public version)
+****************************************************************************/
+int debug_lookup_classname(const char *classname)
+{
+ int ndx;
+
+ if (!classname || !*classname) return -1;
+
+ ndx = debug_lookup_classname_int(classname);
+
+ if (ndx != -1)
+ return ndx;
+
+ if (debug_warn_unknown_class)
+ {
+ DEBUG(0, ("debug_lookup_classname(%s): Unknown class\n",
+ classname));
+ }
+ if (debug_auto_add_unknown_class)
+ {
+ return debug_add_class(classname);
+ }
+ return -1;
+}
+
+
+/****************************************************************************
+dump the current registered denug levels
+****************************************************************************/
+static void debug_dump_status(int level)
+{
+ int q;
+
+ DEBUG(level, ("INFO: Current debug levels:\n"));
+ for (q = 0; q < debug_num_classes; q++)
+ {
+ DEBUGADD(level, (" %s: %s/%d\n",
+ classname_table[q],
+ (DEBUGLEVEL_CLASS_ISSET[q]
+ ? "True" : "False"),
+ DEBUGLEVEL_CLASS[q]));
+ }
+}
+
+/****************************************************************************
parse the debug levels from smbcontrol. Example debug level parameter:
printdrivers:7
****************************************************************************/
@@ -179,9 +376,9 @@ BOOL debug_parse_params(char **params, int *debuglevel_class,
int i, ndx;
char *class_name;
char *class_level;
-
- /* Set the new debug level array to the current DEBUGLEVEL array */
- memcpy(debuglevel_class, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS));
+
+ if (!params)
+ return False;
/* Allow DBGC_ALL to be specified w/o requiring its class name e.g."10"
* v.s. "all:10", this is the traditional way to set DEBUGLEVEL
@@ -195,7 +392,7 @@ BOOL debug_parse_params(char **params, int *debuglevel_class,
i = 0; /* DBGC_ALL not specified OR class name was included */
/* Fill in new debug class levels */
- for (; i < DBGC_LAST && params[i]; i++) {
+ for (; i < debug_num_classes && params[i]; i++) {
if ((class_name=strtok(params[i],":")) &&
(class_level=strtok(NULL, "\0")) &&
((ndx = debug_lookup_classname(class_name)) != -1)) {
@@ -215,83 +412,80 @@ parse the debug levels from smb.conf. Example debug level string:
3 tdb:5 printdrivers:7
Note: the 1st param has no "name:" preceeding it.
****************************************************************************/
-BOOL debug_parse_levels(char *params_str)
+BOOL debug_parse_levels(const char *params_str)
{
- int i;
- char *params[DBGC_LAST];
- int debuglevel_class[DBGC_LAST];
- BOOL debuglevel_class_isset[DBGC_LAST];
+ char **params;
if (AllowDebugChange == False)
- return True;
- ZERO_ARRAY(params);
- ZERO_ARRAY(debuglevel_class);
- ZERO_ARRAY(debuglevel_class_isset);
-
- if ((params[0]=strtok(params_str," ,"))) {
- for (i=1; i<DBGC_LAST;i++) {
- if ((params[i]=strtok(NULL," ,"))==NULL)
- break;
- }
- }
- else
- return False;
-
- if (debug_parse_params(params, debuglevel_class,
- debuglevel_class_isset)) {
- debug_message(0, sys_getpid(), (void*)debuglevel_class, sizeof(debuglevel_class));
-
- memcpy(DEBUGLEVEL_CLASS, debuglevel_class,
- sizeof(debuglevel_class));
-
- memcpy(DEBUGLEVEL_CLASS_ISSET, debuglevel_class_isset,
- sizeof(debuglevel_class_isset));
-
- {
- int q;
+ return True;
- for (q = 0; q < DBGC_LAST; q++)
- DEBUG(5, ("%s: %d/%d\n",
- classname_table[q],
- DEBUGLEVEL_CLASS[q],
- DEBUGLEVEL_CLASS_ISSET[q]));
- }
+ params = lp_list_make(params_str);
+ if (debug_parse_params(params, DEBUGLEVEL_CLASS,
+ DEBUGLEVEL_CLASS_ISSET))
+ {
+ debug_dump_status(5);
+ lp_list_free(&params);
return True;
- } else
+ } else {
+ lp_list_free(&params);
return False;
+ }
}
/****************************************************************************
receive a "set debug level" message
****************************************************************************/
-void debug_message(int msg_type, pid_t src, void *buf, size_t len)
+static void debug_message(int msg_type, pid_t src, void *buf, size_t len)
{
- struct debuglevel_message *dm = (struct debuglevel_message *)buf;
- int i;
+ const char *params_str = buf;
- /* Set the new DEBUGLEVEL_CLASS array from the passed message */
- memcpy(DEBUGLEVEL_CLASS, dm->debuglevel_class, sizeof(dm->debuglevel_class));
- memcpy(DEBUGLEVEL_CLASS_ISSET, dm->debuglevel_class_isset, sizeof(dm->debuglevel_class_isset));
+ /* Check, it's a proper string! */
+ if (params_str[len-1] != '\0')
+ {
+ DEBUG(1, ("Invalid debug message from pid %u to pid %u\n",
+ (unsigned int)src, (unsigned int)getpid()));
+ return;
+ }
- DEBUG(3,("INFO: Debug class %s level = %d (pid %u from pid %u)\n",
- classname_table[DBGC_ALL],
- DEBUGLEVEL_CLASS[DBGC_ALL], (unsigned int)sys_getpid(), (unsigned int)src));
+ DEBUG(3, ("INFO: Remote set of debug to `%s' (pid %u from pid %u)\n",
+ params_str, (unsigned int)getpid(), (unsigned int)src));
- for (i=1; i<DBGC_LAST; i++) {
- if (DEBUGLEVEL_CLASS[i])
- DEBUGADD(3,("INFO: Debug class %s level = %d\n",
- classname_table[i], DEBUGLEVEL_CLASS[i]));
- }
+ debug_parse_levels(params_str);
}
/****************************************************************************
send a "set debug level" message
****************************************************************************/
-void debug_message_send(pid_t pid, int level)
+void debug_message_send(pid_t pid, const char *params_str)
+{
+ if (!params_str)
+ return;
+ message_send_pid(pid, MSG_DEBUG, params_str, strlen(params_str) + 1,
+ False);
+}
+
+
+/****************************************************************************
+Init debugging (one time stuff)
+****************************************************************************/
+void debug_init(void)
{
- message_send_pid(pid, MSG_DEBUG, &level, sizeof(int), False);
+ static BOOL initialised = False;
+ const char **p;
+
+ if (initialised)
+ return;
+
+ initialised = True;
+
+ message_register(MSG_DEBUG, debug_message);
+
+ for(p = default_classname_table; *p; p++)
+ {
+ debug_add_class(*p);
+ }
}
@@ -301,7 +495,7 @@ void debug_message_send(pid_t pid, int level)
*/
void setup_logging(char *pname, BOOL interactive)
{
- message_register(MSG_DEBUG, debug_message);
+ debug_init();
/* reset to allow multiple setup calls, going from interactive to
non-interactive */
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 8602c2f32d..6cb7507c0f 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -92,8 +92,16 @@ void ping_message(int msg_type, pid_t src, void *buf, size_t len)
void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len)
{
+ char *debug_level_classes;
DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %u\n",(unsigned int)src));
- message_send_pid(src, MSG_DEBUGLEVEL, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS), True);
+
+ if (debug_level_classes = debug_list_class_names_and_levels()) {
+ /*{ debug_level_classes = "test:1000";*/
+ message_send_pid(src, MSG_DEBUGLEVEL, debug_level_classes, strlen(debug_level_classes) + 1, True);
+ SAFE_FREE(debug_level_classes);
+ } else {
+ DEBUG(0, ("debuglevel_message: error retrieving class levels!\n"));
+ }
}
/****************************************************************************
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 79eef6ed5e..ff32bdca64 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -55,7 +55,6 @@ BOOL in_client = False; /* Not in the client by default */
BOOL bLoaded = False;
extern userdom_struct current_user_info;
-extern int DEBUGLEVEL_CLASS[DBGC_LAST];
extern pstring user_socket_options;
extern pstring global_myname;
pstring global_scope = "";
@@ -757,8 +756,8 @@ static struct parm_struct parm_table[] = {
{"Logging Options", P_SEP, P_SEPARATOR},
{"admin log", P_BOOL, P_GLOBAL, &Globals.bAdminLog, NULL, NULL, 0},
- {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
- {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL_CLASS[DBGC_ALL], handle_debug_list, NULL, 0},
+ {"log level", P_STRING, P_GLOBAL, NULL, handle_debug_list, NULL, 0},
+ {"debuglevel", P_STRING, P_GLOBAL, NULL, handle_debug_list, NULL, 0},
{"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, 0},
{"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, 0},
{"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, 0},
diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c
index 6436a2cd05..0b4a4ffeba 100644
--- a/source3/passdb/machine_sid.c
+++ b/source3/passdb/machine_sid.c
@@ -22,6 +22,8 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
/****************************************************************************
Read a SID from a file. This is for compatibility with the old MACHINE.SID
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index edae00389e..32d6731a9e 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -23,6 +23,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
/*
* This is set on startup - it defines the SID for this
* machine, and therefore the SAM database for which it is
diff --git a/source3/passdb/passgrp.c b/source3/passdb/passgrp.c
index d7ed965648..f73591793f 100644
--- a/source3/passdb/passgrp.c
+++ b/source3/passdb/passgrp.c
@@ -21,6 +21,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
/*
* NOTE. All these functions are abstracted into a structure
* that points to the correct function for the selected database. JRA.
diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 372b332a45..5ed54a9857 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -23,6 +23,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
/**
* @todo Redefine this to NULL, but this changes the API becouse
* much of samba assumes that the pdb_get...() funtions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 6488decf94..e44d1f8bb4 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -21,6 +21,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
/** List of various built-in passdb modules */
const struct pdb_init_function_entry builtin_pdb_init_functions[] = {
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index e10dc73d0b..46b464a588 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -24,6 +24,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
#ifdef HAVE_LDAP
/* TODO:
* persistent connections: if using NSS LDAP, many connections are made
diff --git a/source3/passdb/pdb_plugin.c b/source3/passdb/pdb_plugin.c
index 1de61abd5f..f7ab2b90e2 100644
--- a/source3/passdb/pdb_plugin.c
+++ b/source3/passdb/pdb_plugin.c
@@ -21,6 +21,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
void * dl_handle;
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c
index e2050627e1..f6214220ea 100644
--- a/source3/passdb/pdb_smbpasswd.c
+++ b/source3/passdb/pdb_smbpasswd.c
@@ -23,6 +23,8 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
/*
smb_passwd is analogous to sam_passwd used everywhere
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 46120c3ccc..37101c39c9 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -2,7 +2,7 @@
* Unix SMB/CIFS implementation.
* SMB parameters and setup
* Copyright (C) Andrew Tridgell 1992-1998
- * Copyright (C) Simo Sorce 2000
+ * Copyright (C) Simo Sorce 2000-2002
* Copyright (C) Gerald Carter 2000
* Copyright (C) Jeremy Allison 2001
* Copyright (C) Andrew Bartlett 2002
@@ -24,6 +24,19 @@
#include "includes.h"
+#if 0 /* when made a module use this */
+
+static int tdbsam_debug_level = DBGC_ALL;
+#undef DBGC_CLASS
+#define DBGC_CLASS tdbsam_debug_level
+
+#else
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
+#endif
+
#ifdef WITH_TDB_SAM
#define PDB_VERSION "20010830"
@@ -880,6 +893,14 @@ NTSTATUS pdb_init_tdbsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con
NTSTATUS nt_status;
struct tdbsam_privates *tdb_state;
+#if 0 /* when made a module use this */
+ tdbsam_debug_level = debug_add_class("tdbsam");
+ if(tdbsam_debug_level == -1) {
+ tdbsam_debug_level = DBGC_ALL;
+ DEBUG(0, ("tdbsam: Couldn't register custom debugging class!\n"));
+ }
+#endif
+
if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods(pdb_context->mem_ctx, pdb_method))) {
return nt_status;
}
@@ -934,7 +955,7 @@ NTSTATUS pdb_init_tdbsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method,
(*pdb_method)->name = "tdbsam_nua";
tdb_state = (*pdb_method)->private_data;
-
+
tdb_state->permit_non_unix_accounts = True;
if (!lp_non_unix_account_range(&low_nua_uid, &high_nua_uid)) {
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index 32d4b42611..43fc3604a0 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -24,6 +24,9 @@
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
static TDB_CONTEXT *tdb;
/* open up the secrets database */
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 6b4cd606d0..9a84af027d 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -76,7 +76,8 @@ static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdst
if (!sam_pwent) return -1;
if (verbosity) {
- printf ("Unix/NT username: %s/%s\n", pdb_get_username(sam_pwent),pdb_get_nt_username(sam_pwent));
+ printf ("Unix username: %s\n", pdb_get_username(sam_pwent));
+ printf ("NT username: %s\n", pdb_get_nt_username(sam_pwent));
if (IS_SAM_UNIX_USER(sam_pwent)) {
uid = pdb_get_uid(sam_pwent);
gid = pdb_get_gid(sam_pwent);
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index d680fa4489..5cb4e4febb 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -3,6 +3,7 @@
program to send control messages to Samba processes
Copyright (C) Andrew Tridgell 1994-1998
Copyright (C) 2001, 2002 by Martin Pool
+ Copyright (C) Simo Sorce 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -106,16 +107,14 @@ Prints out the current Debug level returned by MSG_DEBUGLEVEL
void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len)
{
int i;
- int debuglevel_class[DBGC_LAST];
-
- memcpy(debuglevel_class, buf, len);
-
- printf("Current debug level of PID %u is %d ",(unsigned int)src, debuglevel_class[0]);
- for (i=1;i<DBGC_LAST;i++)
- if (debuglevel_class[i])
- printf("%s:%d ", debug_classname_from_index(i), debuglevel_class[i]);
- printf("\n");
+ char *levels = (char *)buf;
+ pstring dbgcl;
+ printf("Current debug levels of PID %u are:\n",(unsigned int)src);
+
+ while(next_token(&levels, dbgcl, " ", sizeof(pstring)))
+ printf("%s\n", dbgcl);
+
got_level = True;
}
@@ -243,19 +242,36 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
switch (mtype) {
case MSG_DEBUG: {
- struct debuglevel_message dm;
+ char *buf, *b;
+ char **p;
+ int dim = 0;
if (!params || !params[0]) {
fprintf(stderr,"MSG_DEBUG needs a parameter\n");
return(False);
}
- ZERO_STRUCT(dm);
- if (!debug_parse_params(params, dm.debuglevel_class, dm.debuglevel_class_isset)) {
- fprintf(stderr, "MSG_DEBUG error. Expected <class name>:level\n");
+ /* first pass retrieve total lenght */
+ for (p = params; p && *p ; p++)
+ dim += (strnlen(*p, 1024) +1); /* lenght + space */
+ b = buf = malloc(dim);
+ if (!buf) {
+ fprintf(stderr, "Out of memory!");
return(False);
- } else
- send_message(dest, MSG_DEBUG, &dm, sizeof(dm), False);
+ }
+ /* now build a single string with all parameters */
+ for(p = params; p && *p; p++) {
+ int l = strnlen(*p, 1024);
+ strncpy(b, *p, l);
+ b[l] = ' ';
+ b = b + l + 1;
+ }
+ b[-1] = '\0';
+
+ send_message(dest, MSG_DEBUG, buf, dim, False);
+
+ free(buf);
+
break;
}