]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Regression Fix: Make Squid abort on parse failures.
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 21 Dec 2009 12:00:15 +0000 (01:00 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 21 Dec 2009 12:00:15 +0000 (01:00 +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 dcc472e2891fc2bc6b2038fa6519e117d54e38d4..85cbbba2b998a9ffd340265465fce7a1fc19e1c4 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);