util: Add new debug setting debug_no_stderr_redirect
authorMartin Schwenke <martin@meltin.net>
Tue, 7 Jun 2022 03:54:20 +0000 (13:54 +1000)
committerVolker Lendecke <vl@samba.org>
Thu, 16 Jun 2022 12:42:35 +0000 (12:42 +0000)
CTDB doesn't want this redirection of stderr to the log file.  It
expects to be able to capture stderr of subprocesses and log them with
a header.  This redirection stops that from happening.

Unfortunately this has to be a negative option (i.e. "no" in the name)
so that the default of 0/false maintains existing behaviour.

Note that the default behaviour is sub-optimal because it causes raw
data (i.e. debug data without a header) to appear in the log.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15090

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/util/debug.c
lib/util/debug.h

index 8484094d01472b29ac6d29a07a973952fb5e3ef8..7f9231eac2e13b172da89122f94680c5baaf26d1 100644 (file)
@@ -1324,7 +1324,8 @@ bool reopen_logs_internal(void)
         * If log file was opened or created successfully, take over stderr to
         * catch output into logs.
         */
-       if (dbgc_config[DBGC_ALL].fd > 0) {
+       if (!state.settings.debug_no_stderr_redirect &&
+           dbgc_config[DBGC_ALL].fd > 0) {
                if (dup2(dbgc_config[DBGC_ALL].fd, 2) == -1) {
                        /* Close stderr too, if dup2 can't point it -
                           at the logfile.  There really isn't much
index a9f3a41cde4fa59633d523b1f5edb805a98428ad..9aeec853e6484c7798007329f35a2089f055496c 100644 (file)
@@ -305,6 +305,7 @@ struct debug_settings {
        bool debug_pid;
        bool debug_uid;
        bool debug_class;
+       bool debug_no_stderr_redirect;
 };
 
 void setup_logging(const char *prog_name, enum debug_logtype new_logtype);