From: Kees Monshouwer Date: Mon, 9 Dec 2019 22:23:31 +0000 (+0100) Subject: auth: add --config=check option X-Git-Tag: auth-4.3.0-beta2~10^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c360f2017a35fd025603e4b61381484ce7e16bb;p=thirdparty%2Fpdns.git auth: add --config=check option parse the configuration with error checking --- diff --git a/docs/manpages/pdns_server.1.rst b/docs/manpages/pdns_server.1.rst index 9c290b546b..ceb86f12a6 100644 --- a/docs/manpages/pdns_server.1.rst +++ b/docs/manpages/pdns_server.1.rst @@ -27,9 +27,10 @@ See the online documentation for all options --control-console Run the server in a special monitor mode. This enables detailed logging and exposes the raw control socket. --loglevel= Set the logging level. ---config Show the currently configuration. There are two optional values (defaul - is empty). --config=diff will only show modified options. --config=default - will show the default configuration. +--config Show the currently configuration. There are three optional values: + --config=default show the default configuration. + --config=diff show modified options in the curent configuration. + --config=check parse the current configuration, with error checking. --help To view more options that are available use this program. See also diff --git a/pdns/receiver.cc b/pdns/receiver.cc index f3d210d4ca..599e47fdc9 100644 --- a/pdns/receiver.cc +++ b/pdns/receiver.cc @@ -415,7 +415,7 @@ int main(int argc, char **argv) string configname=::arg()["config-dir"]+"/"+s_programname+".conf"; cleanSlashes(configname); - if(!::arg().mustDo("no-config")) // "config" == print a configuration file + if(::arg()["config"] != "default" && !::arg().mustDo("no-config")) // "config" == print a configuration file ::arg().laxFile(configname.c_str()); ::arg().laxParse(argc,argv); // reparse so the commandline still wins @@ -517,6 +517,17 @@ int main(int argc, char **argv) cout<<::arg().configstring(false, true); } else if (config == "diff") { cout<<::arg().configstring(true, false); + } else if (config == "check") { + try { + if(!::arg().mustDo("no-config")) + ::arg().file(configname.c_str()); + ::arg().parse(argc,argv); + exit(0); + } + catch(const ArgException &A) { + cerr<<"Fatal error: "<