diff options
-rw-r--r-- | examples/pdb/pdb_test.c | 44 | ||||
-rw-r--r-- | source/passdb/pdb_interface.c | 35 | ||||
-rw-r--r-- | source/utils/net.c | 14 | ||||
-rw-r--r-- | source/utils/pdbedit.c | 24 | ||||
-rw-r--r-- | source/utils/status.c | 8 |
5 files changed, 70 insertions, 55 deletions
diff --git a/examples/pdb/pdb_test.c b/examples/pdb/pdb_test.c index 4b4189e9d57..983a995d858 100644 --- a/examples/pdb/pdb_test.c +++ b/examples/pdb/pdb_test.c @@ -17,11 +17,15 @@ * Mass Ave, Cambridge, MA 02139, USA. */ + #include "includes.h" +static int testsam_debug_level = DBGC_ALL; +#undef DBGC_CLASS +#define DBGC_CLASS testsam_debug_level -static BOOL testsam_setsampwent(struct pdb_context *context, BOOL update) +static BOOL testsam_setsampwent(struct pdb_methods *methods, BOOL update) { - DEBUG(0, ("testsam_setsampwent called\n")); + DEBUG(10, ("testsam_setsampwent called\n")); return True; } @@ -29,18 +33,18 @@ static BOOL testsam_setsampwent(struct pdb_context *context, BOOL update) End enumeration of the passwd list. ****************************************************************/ -static void testsam_endsampwent(struct pdb_context *context) +static void testsam_endsampwent(struct pdb_methods *methods) { - DEBUG(0, ("testsam_endsampwent called\n")); + DEBUG(10, ("testsam_endsampwent called\n")); } /***************************************************************** Get one SAM_ACCOUNT from the list (next in line) *****************************************************************/ -static BOOL testsam_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user) +static BOOL testsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user) { - DEBUG(0, ("testsam_getsampwent called\n")); + DEBUG(10, ("testsam_getsampwent called\n")); return False; } @@ -48,9 +52,9 @@ static BOOL testsam_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user) Lookup a name in the SAM database ******************************************************************/ -static BOOL testsam_getsampwnam (struct pdb_context *context, SAM_ACCOUNT *user, const char *sname) +static BOOL testsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname) { - DEBUG(0, ("testsam_getsampwnam called\n")); + DEBUG(10, ("testsam_getsampwnam called\n")); return False; } @@ -58,9 +62,9 @@ static BOOL testsam_getsampwnam (struct pdb_context *context, SAM_ACCOUNT *user, Search by rid **************************************************************************/ -static BOOL testsam_getsampwrid (struct pdb_context *context, SAM_ACCOUNT *user, uint32 rid) +static BOOL testsam_getsampwrid (struct pdb_methods *methods, SAM_ACCOUNT *user, uint32 rid) { - DEBUG(0, ("testsam_getsampwrid called\n")); + DEBUG(10, ("testsam_getsampwrid called\n")); return False; } @@ -68,9 +72,9 @@ static BOOL testsam_getsampwrid (struct pdb_context *context, SAM_ACCOUNT *user, Delete a SAM_ACCOUNT ****************************************************************************/ -static BOOL testsam_delete_sam_account(struct pdb_context *context, const SAM_ACCOUNT *sam_pass) +static BOOL testsam_delete_sam_account(struct pdb_methods *methods, const SAM_ACCOUNT *sam_pass) { - DEBUG(0, ("testsam_delete_sam_account called\n")); + DEBUG(10, ("testsam_delete_sam_account called\n")); return False; } @@ -78,9 +82,9 @@ static BOOL testsam_delete_sam_account(struct pdb_context *context, const SAM_AC Modifies an existing SAM_ACCOUNT ****************************************************************************/ -static BOOL testsam_update_sam_account (struct pdb_context *context, const SAM_ACCOUNT *newpwd) +static BOOL testsam_update_sam_account (struct pdb_methods *methods, const SAM_ACCOUNT *newpwd) { - DEBUG(0, ("testsam_update_sam_account called\n")); + DEBUG(10, ("testsam_update_sam_account called\n")); return False; } @@ -88,9 +92,9 @@ static BOOL testsam_update_sam_account (struct pdb_context *context, const SAM_A Adds an existing SAM_ACCOUNT ****************************************************************************/ -static BOOL testsam_add_sam_account (struct pdb_context *context, const SAM_ACCOUNT *newpwd) +static BOOL testsam_add_sam_account (struct pdb_methods *methods, const SAM_ACCOUNT *newpwd) { - DEBUG(0, ("testsam_add_sam_account called\n")); + DEBUG(10, ("testsam_add_sam_account called\n")); return False; } @@ -112,10 +116,16 @@ NTSTATUS pdb_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char (*pdb_method)->add_sam_account = testsam_add_sam_account; (*pdb_method)->update_sam_account = testsam_update_sam_account; (*pdb_method)->delete_sam_account = testsam_delete_sam_account; + + testsam_debug_level = debug_add_class("testsam"); + if (testsam_debug_level == -1) { + testsam_debug_level = DBGC_ALL; + DEBUG(0, ("testsam: Couldn't register custom debugging class!\n")); + } else DEBUG(0, ("testsam: Debug class number of 'testsam': %d\n", testsam_debug_level)); DEBUG(0, ("Initializing testsam\n")); if (location) - DEBUG(0, ("Location: %s\n", location)); + DEBUG(10, ("Location: %s\n", location)); return NT_STATUS_OK; } diff --git a/source/passdb/pdb_interface.c b/source/passdb/pdb_interface.c index e44d1f8bb4e..e57944cda7a 100644 --- a/source/passdb/pdb_interface.c +++ b/source/passdb/pdb_interface.c @@ -66,7 +66,7 @@ static void context_endsampwent(struct pdb_context *context) return; } - if(context->pwent_methods && context->pwent_methods->endsampwent) + if (context->pwent_methods && context->pwent_methods->endsampwent) context->pwent_methods->endsampwent(context->pwent_methods); /* So we won't get strange data when calling getsampwent now */ @@ -80,18 +80,19 @@ static BOOL context_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user) return False; } /* Loop until we find something useful */ - while((!context->pwent_methods->getsampwent) || + while ((!context->pwent_methods->getsampwent) || context->pwent_methods->getsampwent(context->pwent_methods, user) == False){ - if(context->pwent_methods->endsampwent) + if (context->pwent_methods->endsampwent) context->pwent_methods->endsampwent(context->pwent_methods); context->pwent_methods = context->pwent_methods->next; /* All methods are checked now. There are no more entries */ - if(context->pwent_methods == NULL)return False; + if (context->pwent_methods == NULL) + return False; - if(!context->pwent_methods->setsampwent){ + if (!context->pwent_methods->setsampwent){ DEBUG(5, ("invalid context->pwent_methods->setsampwent\n")); return False; } @@ -110,8 +111,8 @@ static BOOL context_getsampwnam(struct pdb_context *context, SAM_ACCOUNT *sam_ac return False; } curmethods = context->pdb_methods; - while(curmethods){ - if(curmethods->getsampwnam && curmethods->getsampwnam(curmethods, sam_acct, username) == True){ + while (curmethods){ + if (curmethods->getsampwnam && curmethods->getsampwnam(curmethods, sam_acct, username) == True){ sam_acct->methods = curmethods; return True; } @@ -131,8 +132,8 @@ static BOOL context_getsampwrid(struct pdb_context *context, SAM_ACCOUNT *sam_ac curmethods = context->pdb_methods; - while(curmethods){ - if(curmethods->getsampwrid && curmethods->getsampwrid(curmethods, sam_acct, rid) == True){ + while (curmethods){ + if (curmethods->getsampwrid && curmethods->getsampwrid(curmethods, sam_acct, rid) == True){ sam_acct->methods = curmethods; return True; } @@ -163,12 +164,12 @@ static BOOL context_update_sam_account(struct pdb_context *context, SAM_ACCOUNT return False; } - if(!sam_acct || !sam_acct->methods){ + if (!sam_acct || !sam_acct->methods){ DEBUG(0, ("invalid sam_acct specified\n")); return False; } - if(!sam_acct->methods->update_sam_account){ + if (!sam_acct->methods->update_sam_account){ DEBUG(0, ("invalid sam_acct->methods\n")); return False; } @@ -186,12 +187,12 @@ static BOOL context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT return False; } - if(!sam_acct->methods){ + if (!sam_acct->methods){ pdb_selected = context->pdb_methods; /* There's no passdb backend specified for this account. * Try to delete it in every passdb available */ - while(pdb_selected){ - if(pdb_selected->delete_sam_account && pdb_selected->delete_sam_account(pdb_selected, sam_acct)){ + while (pdb_selected){ + if (pdb_selected->delete_sam_account && pdb_selected->delete_sam_account(pdb_selected, sam_acct)){ return True; } pdb_selected = pdb_selected->next; @@ -199,7 +200,7 @@ static BOOL context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT return False; } - if(!sam_acct->methods->delete_sam_account){ + if (!sam_acct->methods->delete_sam_account){ DEBUG(0,("invalid sam_acct->methods->delete_sam_account\n")); return False; } @@ -211,8 +212,8 @@ static void free_pdb_context(struct pdb_context **context) { struct pdb_methods *pdb_selected = (*context)->pdb_methods; - while(pdb_selected){ - if(pdb_selected->free_private_data) + while (pdb_selected){ + if (pdb_selected->free_private_data) pdb_selected->free_private_data(pdb_selected->private_data); pdb_selected = pdb_selected->next; } diff --git a/source/utils/net.c b/source/utils/net.c index fc5c6b90d54..b6998efdf77 100644 --- a/source/utils/net.c +++ b/source/utils/net.c @@ -77,6 +77,7 @@ BOOL opt_have_ip = False; struct in_addr opt_dest_ip; extern pstring global_myname; +extern BOOL AllowDebugChange; /* run a function from a function table. If not found then @@ -356,7 +357,7 @@ static struct functable net_func[] = { const char ** argv_new; poptContext pc; static char *servicesf = dyn_CONFIGFILE; - static int debuglevel = 0; + static char *debuglevel = NULL; struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, 'h'}, @@ -367,8 +368,8 @@ static struct functable net_func[] = { {"port", 'p', POPT_ARG_INT, &opt_port}, {"myname", 'n', POPT_ARG_STRING, &opt_requester_name}, {"conf", 's', POPT_ARG_STRING, &servicesf}, - {"debug", 'd', POPT_ARG_INT, &debuglevel}, - {"debuglevel", 'd', POPT_ARG_INT, &debuglevel}, + {"debug", 'd', POPT_ARG_STRING, &debuglevel}, + {"debuglevel", 'd', POPT_ARG_STRING, &debuglevel}, {"server", 'S', POPT_ARG_STRING, &opt_host}, {"comment", 'C', POPT_ARG_STRING, &opt_comment}, {"maxusers", 'M', POPT_ARG_INT, &opt_maxusers}, @@ -416,9 +417,12 @@ static struct functable net_func[] = { } } - lp_load(servicesf,True,False,False); + if (debuglevel) { + debug_parse_levels(debuglevel); + AllowDebugChange = False; + } - DEBUGLEVEL = debuglevel; + lp_load(servicesf,True,False,False); argv_new = (const char **)poptGetArgs(pc); diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c index 9a84af027df..51254667c9b 100644 --- a/source/utils/pdbedit.c +++ b/source/utils/pdbedit.c @@ -34,24 +34,24 @@ int export_database (struct pdb_context *in, char *db){ struct pdb_context *context; SAM_ACCOUNT *user = NULL; - if(!NT_STATUS_IS_OK(make_pdb_context_name(&context, db))){ + if (!NT_STATUS_IS_OK(make_pdb_context_name(&context, db))){ fprintf(stderr, "Can't initialize %s.\n", db); return 1; } - if(!in->pdb_setsampwent(in, 0)){ + if (!in->pdb_setsampwent(in, 0)){ fprintf(stderr, "Can't sampwent!\n"); return 1; } - if(!NT_STATUS_IS_OK(pdb_init_sam(&user))){ + if (!NT_STATUS_IS_OK(pdb_init_sam(&user))){ fprintf(stderr, "Can't initialize new SAM_ACCOUNT!\n"); return 1; } - while(in->pdb_getsampwent(in,user)){ + while (in->pdb_getsampwent(in,user)){ context->pdb_add_sam_account(context,user); - if(!NT_STATUS_IS_OK(pdb_reset_sam(user))){ + if (!NT_STATUS_IS_OK(pdb_reset_sam(user))){ fprintf(stderr, "Can't reset SAM_ACCOUNT!\n"); return 1; } @@ -411,7 +411,7 @@ int main (int argc, char **argv) static char *logon_script = NULL; static char *profile_path = NULL; static char *config_file = dyn_CONFIGFILE; - static int new_debuglevel = -1; + static char *new_debuglevel = NULL; struct pdb_context *in; poptContext pc; @@ -431,22 +431,21 @@ int main (int argc, char **argv) {"delete", 'x',POPT_ARG_VAL,&delete_user,1,"delete user",NULL}, {"import", 'i',POPT_ARG_STRING,&backend_in,0,"use different passdb backend",NULL}, {"export", 'e',POPT_ARG_STRING,&backend_out,0,"export user accounts to backend", NULL}, - {"debuglevel",'D', POPT_ARG_INT, &new_debuglevel,0,"set debuglevel",NULL}, + {"debuglevel",'D', POPT_ARG_STRING, &new_debuglevel,0,"set debuglevel",NULL}, {"configfile",'c',POPT_ARG_STRING, &config_file,0,"use different configuration file",NULL}, {0,0,0,0} }; - DEBUGLEVEL = 1; setup_logging("pdbedit", True); - AllowDebugChange = False; pc = poptGetContext(NULL, argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1); - if (new_debuglevel != -1) { - DEBUGLEVEL = new_debuglevel; + if (new_debuglevel){ + debug_parse_levels(new_debuglevel); + AllowDebugChange = False; } if (!lp_load(config_file,True,False,False)) { @@ -455,6 +454,7 @@ int main (int argc, char **argv) exit(1); } + if (!backend_in) { backend_in = lp_passdb_backend(); } @@ -467,7 +467,7 @@ int main (int argc, char **argv) } - if(!NT_STATUS_IS_OK(make_pdb_context_name(&in, backend_in))){ + if (!NT_STATUS_IS_OK(make_pdb_context_name(&in, backend_in))){ fprintf(stderr, "Can't initialize %s.\n", backend_in); return 1; } diff --git a/source/utils/status.c b/source/utils/status.c index f230cd8466d..b1e8bb9d8e1 100644 --- a/source/utils/status.c +++ b/source/utils/status.c @@ -546,7 +546,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo { int c; static int profile_only = 0; - static int new_debuglevel = -1; + static char *new_debuglevel = NULL; TDB_CONTEXT *tdb; poptContext pc; struct poptOption long_options[] = { @@ -559,7 +559,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo {"brief", 'b', POPT_ARG_NONE, &brief}, {"profile", 'P', POPT_ARG_NONE, &profile_only}, {"byterange", 'B', POPT_ARG_NONE, &show_brl}, - {"debug", 'd', POPT_ARG_INT, &new_debuglevel}, + {"debug", 'd', POPT_ARG_STRING, &new_debuglevel}, { 0, 0, 0, 0} }; @@ -597,8 +597,8 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo return (-1); } - if (new_debuglevel != -1) { - DEBUGLEVEL = new_debuglevel; + if (new_debuglevel) { + debug_parse_levels(new_debuglevel); } if (verbose) { |