]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: command-line option -D must have precedence over "debug"
authorWilly Tarreau <w@1wt.eu>
Fri, 26 Oct 2012 14:04:28 +0000 (16:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 26 Oct 2012 14:04:28 +0000 (16:04 +0200)
From the beginning it has been said that -D must always be used on the
command line from startup scripts so that haproxy does not accidentally
stay in foreground when loaded from init script... Except that this has
not been true for a long time now.

The fix is easy and must be backported to 1.4 too which is affected.

src/haproxy.c

index f296f716f40bdc72db3b690a124db27141e77424..74c1e5b68ef2d4ad7d3e9161e6b047bda3f17c29 100644 (file)
@@ -710,9 +710,16 @@ void init(int argc, char **argv)
        if (arg_mode & (MODE_DEBUG | MODE_FOREGROUND)) {
                /* command line debug mode inhibits configuration mode */
                global.mode &= ~(MODE_DAEMON | MODE_QUIET);
+               global.mode |= (arg_mode & (MODE_DEBUG | MODE_FOREGROUND));
        }
-       global.mode |= (arg_mode & (MODE_DAEMON | MODE_FOREGROUND | MODE_QUIET |
-                                   MODE_VERBOSE | MODE_DEBUG ));
+
+       if (arg_mode & MODE_DAEMON) {
+               /* command line daemon mode inhibits foreground and debug modes mode */
+               global.mode &= ~(MODE_DEBUG | MODE_FOREGROUND);
+               global.mode |= (arg_mode & MODE_DAEMON);
+       }
+
+       global.mode |= (arg_mode & (MODE_QUIET | MODE_VERBOSE));
 
        if ((global.mode & MODE_DEBUG) && (global.mode & (MODE_DAEMON | MODE_QUIET))) {
                Warning("<debug> mode incompatible with <quiet> and <daemon>. Keeping <debug> only.\n");