summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-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());
}