]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Regression Fix: Make Squid abort on parse failures.
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 13 Jan 2010 04:17:42 +0000 (17:17 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 13 Jan 2010 04:17:42 +0000 (17:17 +1300)
The addition of multi-file parsing and catching of thrown errors between
them caused any errors in sub-files to be non-fatal and allow Squid to
run as if everything was normal, even if parts of the config were not
being loaded.

Squid will now propigate the error exception out and exit with a count of
the errors found.

src/main.cc

index cc5cff2dc7ceb17b4b694bb945086c723cab7dab..a6bd4127ed16fc926f95137169dddba13cd985db 100644 (file)
@@ -720,7 +720,11 @@ mainReconfigureFinish(void *)
     if (Config2.onoff.enable_purge)
         Config2.onoff.enable_purge = 2;
 
-    parseConfigFile(ConfigFile);
+    // parse the config returns a count of errors encountered.
+    if ( parseConfigFile(ConfigFile) != 0) {
+        // for now any errors are a fatal condition...
+        self_destruct();
+    }
 
     setUmask(Config.umask);
     Mem::Report();
@@ -1119,13 +1123,16 @@ static int SquidMainSafe(int argc, char **argv);
 /* When USE_WIN32_SERVICE is defined, the main function is placed in win32.cc */
 extern "C" void WINAPI
 SquidWinSvcMain(int argc, char **argv)
+{
+    SquidMainSafe(argc, argv);
+}
 #else
 int
 main(int argc, char **argv)
-#endif
 {
-    SquidMainSafe(argc, argv);
+    return SquidMainSafe(argc, argv);
 }
+#endif
 
 static int
 SquidMainSafe(int argc, char **argv)
@@ -1260,8 +1267,7 @@ SquidMain(int argc, char **argv)
 
         Mem::Report();
 
-        if (opt_parse_cfg_only)
-
+        if (opt_parse_cfg_only || parse_err > 0)
             return parse_err;
     }
     setUmask(Config.umask);