diff options
author | Andrew Bartlett <abartlet@samba.org> | 2002-05-24 09:57:48 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2002-05-24 09:57:48 +0000 |
commit | 98d5699d28c687f8af5671c9a29aa55dd5a01bfd (patch) | |
tree | 0e95ed256cb1c37b2ad22d5d5e71c37bba49bfcc /source3/utils | |
parent | f5adb7909306b247695024dd7803353fa536a09a (diff) | |
download | samba-98d5699d28c687f8af5671c9a29aa55dd5a01bfd.tar.gz samba-98d5699d28c687f8af5671c9a29aa55dd5a01bfd.tar.bz2 samba-98d5699d28c687f8af5671c9a29aa55dd5a01bfd.zip |
Some of the updates from ctrlsoft's 'Various' patch:
- convert net to popt
- convert status to popt
- adapt examples/pdb/ to multiple passdb system
- add dynamic debug class example to examples/pdb/
and some reformatting to better match the samba coding style.
Andrew Bartlett
(This used to be commit 2498bc69d4e5c38ec385f640489daa94c508c726)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net.c | 14 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 24 | ||||
-rw-r--r-- | source3/utils/status.c | 8 |
3 files changed, 25 insertions, 21 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c index fc5c6b90d5..b6998efdf7 100644 --- a/source3/utils/net.c +++ b/source3/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/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 9a84af027d..51254667c9 100644 --- a/source3/utils/pdbedit.c +++ b/source3/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/source3/utils/status.c b/source3/utils/status.c index f230cd8466..b1e8bb9d8e 100644 --- a/source3/utils/status.c +++ b/source3/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) { |