]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: add --config=check option 8094/head
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 9 Dec 2019 22:23:31 +0000 (23:23 +0100)
committermind04 <mind04@monshouwer.org>
Mon, 9 Dec 2019 22:24:14 +0000 (23:24 +0100)
parse the configuration with error checking

docs/manpages/pdns_server.1.rst
pdns/receiver.cc

index 9c290b546beec44f2409f521f1200dac4ce0b1f7..ceb86f12a6874f48052e43ebdfe56b7d1aa7948f 100644 (file)
@@ -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=<LEVEL>      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
index f3d210d4caacb3ddf81fa3e4a6ba14cb797db92d..599e47fdc98ec33f22ab0ec40ea2ee23a18f3ebd 100644 (file)
@@ -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: "<<A.reason<<endl;
+          exit(1);
+        }
       } else {
         cout<<::arg().configstring(true, true);
       }