]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: init: automatically turn "set-dumpable" on when using "-d"
authorWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 13:15:11 +0000 (14:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 14:06:15 +0000 (15:06 +0100)
Since we started to automatically chroot for unprivileged users, it
has become really annoying for developers to get a core file during
their testing. Let's always turn "set-dumpable" on when debug mode
is forced on via "-d".

doc/configuration.txt
doc/management.txt
src/haproxy.c

index 0170ff7ac98dd7dfa16509f2d0b7685476b782bf..c5ffbd4d212f0a83f0dbfd5bd963944d9ae91cc5 100644 (file)
@@ -3520,7 +3520,8 @@ set-dumpable [ on | off | libs ]
   command line to enable core dumps. This is for example the case with
   generated configurations and regression testing. In this case, it is possible
   to preset the set-dumpable argument in the HAPROXY_FORCE_DUMPABLE environment
-  variable, which accepts the same values.
+  variable, which accepts the same values. The forced debug mode on the command
+  line ("-d") also turns set-dumpable on.
 
 set-var <var-name> <expr>
   Sets the process-wide variable '<var-name>' to the result of the evaluation
index 9450addd840cdb0e93b1fabc730090f9819576b7..0b24df2f1460ed41f7294c55c3fec8f1388c4017 100644 (file)
@@ -212,8 +212,10 @@ list of options is :
     condition is false or 2 if an error is encountered.
 
   -d : enable debug mode. This disables daemon mode, forces the process to stay
-    in foreground and to show incoming and outgoing events. It must never be
-    used in an init script.
+    in foreground and to show incoming and outgoing events. It also forcefully
+    enables "set-dumpable" in order to produce core dumps on crashes. This is
+    essentially meant to be used by developers. It must never be used in an
+    init script.
 
   -dA[file] : dump an archive of all dependencies detected at boot time in the
     designated file in tar format, immediately after the configuration is done
@@ -5424,8 +5426,9 @@ global "set-dumpable" directive helps to re-enable them despite certain uid/gid
 and chroot changes. When editing the configuration is not an option, such as
 when dealing with generated configurations or regression tests, it is possible
 to set the HAPROXY_FORCE_DUMPABLE environment variable to one of the values
-accepted by "set-dumpable". Please consult the configuration manual for more
-information on this topic.
+accepted by "set-dumpable". For developers who rely a lot on "-d", it also
+automatically enables "set-dumpable". Please consult the configuration manual
+for more information on this topic.
 
 
 13. Security considerations
index ea03e5b8467ef3ce742eaa42e1652f44317afe95..146ea0160b8e9db6cc70bed8060e2e9aedd24f6a 100644 (file)
@@ -1882,6 +1882,10 @@ static void init_args(int argc, char **argv)
        }
 
        haproxy_init_args(argc, argv);
+
+       /* always enable dumpable mode in debug mode (-d) */
+       if (arg_mode & MODE_DEBUG)
+               global.tune.options |= GTUNE_SET_DUMPABLE;
 }
 
 /* call the various keyword dump functions based on the comma-delimited list of