summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-05-24 09:57:48 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-05-24 09:57:48 +0000
commit98d5699d28c687f8af5671c9a29aa55dd5a01bfd (patch)
tree0e95ed256cb1c37b2ad22d5d5e71c37bba49bfcc /source3
parentf5adb7909306b247695024dd7803353fa536a09a (diff)
downloadsamba-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')
-rw-r--r--source3/passdb/pdb_interface.c35
-rw-r--r--source3/utils/net.c14
-rw-r--r--source3/utils/pdbedit.c24
-rw-r--r--source3/utils/status.c8
4 files changed, 43 insertions, 38 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index e44d1f8bb4..e57944cda7 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/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/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) {