[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Jun 16 13:34:02 UTC 2022


The branch, master has been updated
       via  e752f841e68 ctdb-daemon: Use DEBUG() macro for child logging
       via  88f35cf8628 ctdb-daemon: Drop unused prefix, logfn, logfn_private
       via  1596a3e84ba ctdb-common: Tell file logging not to redirect stderr
       via  a8091bd0c56 util: Add new debug setting debug_no_stderr_redirect
      from  d9e561a89a2 s3:tests: Reformat test_smbclient_s3.sh

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e752f841e682cc571006c09249b03d82aea5f8cd
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 6 18:02:31 2022 +1000

    ctdb-daemon: Use DEBUG() macro for child logging
    
    Directly using dbgtext() with file logging results in a log entry with
    no header, which is wrong.  This is a regression, introduced in commit
    10d15c9e5dfe4e8595d0b322c96f474fc7078f46.  Prior to this, CTDB's
    callback for file logging would always add a header.
    
    Use DEBUG() instead dbgtext().  Note that DEBUG() effectively compares
    the passed script_log_level with DEBUGLEVEL, so an explicit check is
    no longer necessary.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15090
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Jun 16 13:33:10 UTC 2022 on sn-devel-184

commit 88f35cf86285b7a818282d5f465711de66dfad59
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 6 17:57:51 2022 +1000

    ctdb-daemon: Drop unused prefix, logfn, logfn_private
    
    These aren't set anywhere in the code.
    
    Drop the log argument because it is also no longer used.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15090
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 1596a3e84babb8fdd86af0c4b98906b309be7907
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 7 14:00:49 2022 +1000

    ctdb-common: Tell file logging not to redirect stderr
    
    This allows ctdb_set_child_logging() to work.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15090
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a8091bd0c565a3f14542731e642319dbb68b4786
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 7 13:54:20 2022 +1000

    util: Add new debug setting debug_no_stderr_redirect
    
    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 at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/common/logging.c      |  1 +
 ctdb/server/ctdb_logging.c | 23 ++++-------------------
 lib/util/debug.c           |  3 ++-
 lib/util/debug.h           |  1 +
 4 files changed, 8 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c
index 1b91cdcc92b..3aa5ca996ee 100644
--- a/ctdb/common/logging.c
+++ b/ctdb/common/logging.c
@@ -148,6 +148,7 @@ static int file_log_setup(TALLOC_CTX *mem_ctx,
 	struct debug_settings settings = {
 		.debug_syslog_format = true,
 		.debug_hires_timestamp = true,
+		.debug_no_stderr_redirect = true,
 	};
 	const char *t = NULL;
 
diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c
index 8af787c189f..1da26b5534c 100644
--- a/ctdb/server/ctdb_logging.c
+++ b/ctdb/server/ctdb_logging.c
@@ -38,12 +38,9 @@
 #include "common/logging.h"
 
 struct ctdb_log_state {
-	const char *prefix;
 	int fd, pfd;
 	char buf[1024];
 	uint16_t buf_used;
-	void (*logfn)(const char *, uint16_t, void *);
-	void *logfn_private;
 };
 
 /* Used by ctdb_set_child_logging() */
@@ -68,21 +65,9 @@ bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging,
 	return true;
 }
 
-/* Note that do_debug always uses the global log state. */
-static void write_to_log(struct ctdb_log_state *log,
-			 const char *buf, unsigned int len)
+static void write_to_log(const char *buf, unsigned int len)
 {
-	if (script_log_level <= DEBUGLEVEL) {
-		if (log != NULL && log->prefix != NULL) {
-			dbgtext("%s: %*.*s\n", log->prefix, len, len, buf);
-		} else {
-			dbgtext("%*.*s\n", len, len, buf);
-		}
-		/* log it in the eventsystem as well */
-		if (log && log->logfn) {
-			log->logfn(log->buf, len, log->logfn_private);
-		}
-	}
+	DEBUG(script_log_level, ("%*.*s\n", len, len, buf));
 }
 
 /*
@@ -119,7 +104,7 @@ static void ctdb_child_log_handler(struct tevent_context *ev,
 		if (n2 > 0 && log->buf[n2-1] == '\r') {
 			n2--;
 		}
-		write_to_log(log, log->buf, n2);
+		write_to_log(log->buf, n2);
 		memmove(log->buf, p+1, sizeof(log->buf) - n1);
 		log->buf_used -= n1;
 	}
@@ -127,7 +112,7 @@ static void ctdb_child_log_handler(struct tevent_context *ev,
 	/* the buffer could have completely filled - unfortunately we have
 	   no choice but to dump it out straight away */
 	if (log->buf_used == sizeof(log->buf)) {
-		write_to_log(log, log->buf, log->buf_used);
+		write_to_log(log->buf, log->buf_used);
 		log->buf_used = 0;
 	}
 }
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 8484094d014..7f9231eac2e 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -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
diff --git a/lib/util/debug.h b/lib/util/debug.h
index a9f3a41cde4..9aeec853e64 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -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);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list