summaryrefslogtreecommitdiff
path: root/source3/utils/testparm.c
diff options
context:
space:
mode:
authorLars Müller <lmuelle@samba.org>2005-06-12 16:00:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:10 -0500
commitbf66eb3a92a0b111f005826696430d934d1187e5 (patch)
tree09d4838873c052e74c82045994569dcd34846d59 /source3/utils/testparm.c
parentc3fedee2a67966e4640b26dd084e75125e58f55c (diff)
downloadsamba-bf66eb3a92a0b111f005826696430d934d1187e5.tar.gz
samba-bf66eb3a92a0b111f005826696430d934d1187e5.tar.bz2
samba-bf66eb3a92a0b111f005826696430d934d1187e5.zip
r7511: Add three new command line switches to testparm:
--show-all-parameters Enumerates all available parameters, grouped in to sections [local] and [global] by the class of the parameter. Each line is formated name=type[,enum values],flags --parameter-name Display the setting of the named parameter. The global section is assumed if no other is set with --section-name --section-name Limit the view of testparm to the named section. Use 'global' to only view the settings of the global section. This fixes bug #2767. Lars (This used to be commit a1b82624d739b1066c356dd4b689233f3c36814e)
Diffstat (limited to 'source3/utils/testparm.c')
-rw-r--r--source3/utils/testparm.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index dfd12c7a58..2b72479ac0 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -201,9 +201,12 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
const char *config_file = dyn_CONFIGFILE;
int s;
static BOOL silent_mode = False;
+ static BOOL show_all_parameters = False;
int ret = 0;
poptContext pc;
static const char *term_code = "";
+ static char *parameter_name = NULL;
+ static char *section_name = NULL;
static char *new_local_machine = NULL;
const char *cname;
const char *caddr;
@@ -215,6 +218,9 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
{"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"},
{"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"},
{"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"},
+ {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" },
+ {"parameter-name", '\0', POPT_ARG_STRING, &parameter_name, 0, "Limit testparm to a named parameter" },
+ {"section-name", '\0', POPT_ARG_STRING, &section_name, 0, "Limit testparm to a named section" },
POPT_COMMON_VERSION
POPT_TABLEEND
};
@@ -225,6 +231,11 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
while(poptGetNextOpt(pc) != -1);
+ if (show_all_parameters) {
+ show_parameter_list();
+ exit(0);
+ }
+
setup_logging(poptGetArg(pc), True);
if (poptPeekArg(pc))
@@ -331,7 +342,7 @@ print command parameter is ignored when using CUPS libraries.\n",
}
- if (!silent_mode) {
+ if (!silent_mode && !section_name && !parameter_name) {
fprintf(stderr,"Server role: ");
switch(lp_server_role()) {
case ROLE_STANDALONE:
@@ -358,6 +369,34 @@ print command parameter is ignored when using CUPS libraries.\n",
fflush(stdout);
getc(stdin);
}
+ if (parameter_name || section_name) {
+ BOOL isGlobal = False;
+ s = GLOBAL_SECTION_SNUM;
+
+ if (!section_name) {
+ section_name = GLOBAL_NAME;
+ isGlobal = True;
+ } else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
+ (s=lp_servicenumber(section_name)) == -1) {
+ fprintf(stderr,"Unknown section %s\n",
+ section_name);
+ return(1);
+ }
+ if (parameter_name) {
+ if (!dump_a_parameter( s, parameter_name, stdout, isGlobal)) {
+ fprintf(stderr,"Parameter %s unknown for section %s\n",
+ parameter_name, section_name);
+ return(1);
+ }
+ } else {
+ if (isGlobal == True)
+ lp_dump(stdout, show_defaults, 0);
+ else
+ lp_dump_one(stdout, show_defaults, s);
+ }
+ return(ret);
+ }
+
lp_dump(stdout, show_defaults, lp_numservices());
}