summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-06-13 08:12:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:06 -0500
commit2b4791ae733488845b2c36bca64db695203de571 (patch)
treee6c3836a90b412e61b10d30f3b256092b46811c7 /source4/lib/registry
parent8fd5825a890db4f08966e4b262b03fb7868cc4c2 (diff)
downloadsamba-2b4791ae733488845b2c36bca64db695203de571.tar.gz
samba-2b4791ae733488845b2c36bca64db695203de571.tar.bz2
samba-2b4791ae733488845b2c36bca64db695203de571.zip
r7525: Unify lp_load(), load_interfaces and logging setup into popt().
There is now a new --debug-stderr option to enable debug to STDERR. popt isn't perfect, but the callbacks are used in all the main Samba binaries, and should be used in the rest. This avoids duplicated code, and ensures every binary is setup correctly. This also ensures the setup happens early enough to have -s function, and have a correct impact on the credentials code. (Fixing a bug that frustrated tridge earlier today). The only 'subtle' aspect of all this is that I'm pretty sure that the SAMBA_COMMON popt code must be above the CREDENTIALS code, in the popt tables. Andrew Bartlett (This used to be commit 50f3c2b3a22971f40e0d3a88127b5120bfc47591)
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/tools/regdiff.c10
-rw-r--r--source4/lib/registry/tools/regpatch.c10
-rw-r--r--source4/lib/registry/tools/regshell.c11
-rw-r--r--source4/lib/registry/tools/regtree.c10
4 files changed, 10 insertions, 31 deletions
diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c
index 4260a56142..f86c0ae383 100644
--- a/source4/lib/registry/tools/regdiff.c
+++ b/source4/lib/registry/tools/regdiff.c
@@ -121,21 +121,18 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey,
WERROR error, error2;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_CREDENTIALS
{"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL },
{"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL", NULL },
{"remote", 'R', POPT_ARG_STRING, NULL, 0, "Connect to remote server" , NULL },
{"local", 'L', POPT_ARG_NONE, NULL, 0, "Open local registry", NULL },
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
POPT_TABLEEND
};
regdiff_init_subsystems;
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
- }
-
-
pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
while((opt = poptGetNextOpt(pc)) != -1) {
@@ -157,7 +154,6 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey,
return 1;
}
}
- setup_logging(argv[0], DEBUG_STDOUT);
poptFreeContext(pc);
diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c
index 5c9851b71b..02ef4d4655 100644
--- a/source4/lib/registry/tools/regpatch.c
+++ b/source4/lib/registry/tools/regpatch.c
@@ -749,25 +749,19 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd
WERROR error;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_CREDENTIALS
{"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL},
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CREDENTIALS
POPT_TABLEEND
};
regpatch_init_subsystems;
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
- }
-
-
pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
while((opt = poptGetNextOpt(pc)) != -1) {
}
- setup_logging(argv[0], DEBUG_STDOUT);
-
if (remote) {
error = reg_open_remote (&h, cmdline_credentials, remote);
} else {
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 03cb09c443..0c53f737b8 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -374,26 +374,21 @@ static char **reg_completion(const char *text, int start, int end)
struct registry_context *h = NULL;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_CREDENTIALS
{"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL},
{"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL},
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
POPT_TABLEEND
};
regshell_init_subsystems;
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
- }
-
-
pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
while((opt = poptGetNextOpt(pc)) != -1) {
}
- setup_logging("regtree", DEBUG_STDOUT);
-
if (remote) {
error = reg_open_remote (&h, cmdline_credentials, remote);
} else if (backend) {
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index 2cf5f6ab96..f18467b523 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -82,28 +82,22 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
int fullpath = 0, no_values = 0;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_CREDENTIALS
{"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL},
{"fullpath", 'f', POPT_ARG_NONE, &fullpath, 0, "show full paths", NULL},
{"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL },
{"no-values", 'V', POPT_ARG_NONE, &no_values, 0, "don't show values", NULL},
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CREDENTIALS
POPT_TABLEEND
};
regtree_init_subsystems;
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
- }
-
-
pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
while((opt = poptGetNextOpt(pc)) != -1) {
}
- setup_logging("regtree", DEBUG_STDOUT);
-
if (remote) {
error = reg_open_remote(&h, cmdline_credentials, remote);
} else if (backend) {