]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] config: fix error message when config file is not found
authorWilly Tarreau <w@1wt.eu>
Sun, 6 Dec 2009 12:10:44 +0000 (13:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 6 Dec 2009 12:10:44 +0000 (13:10 +0100)
Cameron Simpson reported an annoying case where haproxy simply reports
"Error(s) found in configuration file" when the file is not found or
not readable.

Fortunately the parsing function still returns -1 in case of open
error, so we're able to detect the issue from the caller and report
the corresponding errno message.

src/haproxy.c

index 43aee22a5f4b00a2a50cbebe64294fd886e481f0..c5558ca40da217687e57cb410f6de9c06cfabc47 100644 (file)
@@ -541,7 +541,15 @@ void init(int argc, char **argv)
        init_default_instance();
 
        for (i = 0; i < cfg_nbcfgfiles; i++) {
-               err_code |= readcfgfile(cfg_cfgfile[i]);
+               int ret;
+
+               ret = readcfgfile(cfg_cfgfile[i]);
+               if (ret == -1) {
+                       Alert("Could not open configuration file %s : %s\n",
+                             cfg_cfgfile[i], strerror(errno));
+                       exit(1);
+               }
+               err_code |= ret;
                if (err_code & (ERR_ABORT|ERR_FATAL))
                        Alert("Error(s) found in configuration file : %s\n", cfg_cfgfile[i]);
                if (err_code & ERR_ABORT)