]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: fcgi-app: Resolve the sink if a fcgi-app logs in a ring buffer
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 22 Jun 2020 09:07:18 +0000 (11:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 22 Jun 2020 09:35:55 +0000 (11:35 +0200)
If a fcgi application is configured to send its logs to a ring buffer, the
corresponding sink must be resolved during the configuration post
parsing. Otherwise, the sink is undefined when a log message is emitted,
crashing HAProxy.

No need to backport.

src/fcgi-app.c

index 964cc7d3f6800131bc1802fd2ba46a2c11025b07..3f315a6cf97612c6ac4e572508976fddd7979cf5 100644 (file)
@@ -26,6 +26,7 @@
 #include <haproxy/sample.h>
 #include <haproxy/server-t.h>
 #include <haproxy/session.h>
+#include <haproxy/sink.h>
 #include <haproxy/tools.h>
 
 
@@ -646,6 +647,7 @@ static int cfg_fcgi_apps_postparser()
        struct fcgi_app *curapp;
        struct proxy *px;
        struct server *srv;
+       struct logsrv *logsrv;
        int err_code = 0;
 
        for (px = proxies_list; px; px = px->next) {
@@ -694,6 +696,19 @@ static int cfg_fcgi_apps_postparser()
                        }
                        curapp->maxreqs = 1;
                }
+
+               list_for_each_entry(logsrv, &curapp->logsrvs, list) {
+                       if (logsrv->type == LOG_TARGET_BUFFER) {
+                               struct sink *sink = sink_find(logsrv->ring_name);
+
+                               if (!sink || sink->type != SINK_TYPE_BUFFER) {
+                                       ha_alert("config : fcgi-app '%s' : log server uses unkown ring named '%s'.\n",
+                                                curapp->name, logsrv->ring_name);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                               }
+                               logsrv->sink = sink;
+                       }
+               }
        }
 
   end: