]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] log: option tcplog would log to global if no logger was defined
authorWilly Tarreau <w@1wt.eu>
Sun, 9 Aug 2009 08:11:45 +0000 (10:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 9 Aug 2009 14:16:38 +0000 (16:16 +0200)
Romuald du Song reported a strange bug causing "option tcplog" to
unexpectedly use global log parameters if no log server was declared.

Eventhough it can be useful in some circumstances, it only hides
configuration bugs and can even cause traffic logs to be sent to
the wrong logger, since global settings are just for the process.

This has been fixed and a warning has been added for configurations
where tcplog or httplog are set without any logger. This fix must
be backported to 1.3.20, but not to 1.3.15.X in order not to risk
any regression on old configurations.
(cherry picked from commit e7ded1f8698ab954656106baae9cc8da00567511)

src/cfgparse.c
src/log.c

index d8000e175e5f45ea61a976c86b722a98338fd912..b485808ca7eedf0d64da127e7a00defd0b1555d4 100644 (file)
@@ -3892,6 +3892,13 @@ int check_config_validity()
                if (curproxy->options & PR_O_LOGASAP)
                        curproxy->to_log &= ~LW_BYTES;
 
+               if ((curproxy->mode == PR_MODE_TCP || curproxy->mode == PR_MODE_HTTP) &&
+                   (curproxy->cap & PR_CAP_FE) && curproxy->to_log && curproxy->logfac1 < 0) {
+                       Warning("config : log format ignored for %s '%s' since it has no log address.\n",
+                               proxy_type_str(curproxy), curproxy->id);
+                       err_code |= ERR_WARN;
+               }
+
                /*
                 * ensure that we're not cross-dressing a TCP server into HTTP.
                 */
index 093accb28735e9b40389ab66559a24990b85db2b..8d71eae3f5381e2b41163a049c0efd1facf739b0 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -345,20 +345,10 @@ void tcp_sess_log(struct session *s)
 
        get_localtime(s->logs.tv_accept.tv_sec, &tm);
 
-       if (fe->logfac1 >= 0)
-               prx_log = fe;
-       /*
-        * FIXME: should we fall back to the backend if the frontend did not
-        * define any log ? It seems like we should not permit such complex
-        * setups because they would induce a debugging nightmare for the
-        * admin.
-        */
-       // else if (be->logfac1 >= 0)
-       // prx_log = be;
-       else
-               prx_log = NULL; /* global */
+       if (fe->logfac1 < 0 && fe->logfac2 < 0)
+               return;
 
-       /* FIXME: let's limit ourselves to frontend logging for now. */
+       prx_log = fe;
        tolog = fe->to_log;
        svid = (tolog & LW_SVID) ? (s->srv != NULL) ? s->srv->id : "<NOSRV>" : "-";