[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Mon May 30 11:04:01 UTC 2022


The branch, master has been updated
       via  3567f4130d8 debug: update comments about setup_logging()
       via  9537ac723cf cmdline_s4: re-initialise logging once loadparm is ready
      from  5e00c230ec8 py:gpo: Fix testing of 0x8000 bit

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


- Log -----------------------------------------------------------------
commit 3567f4130d8f6193014dc7a1e06c07ecd0c98970
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu May 26 15:50:23 2022 +1200

    debug: update comments about setup_logging()
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon May 30 11:03:47 UTC 2022 on sn-devel-184

commit 9537ac723cfdc43e718fdd08dc28883e7057a372
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu May 26 15:46:08 2022 +1200

    cmdline_s4: re-initialise logging once loadparm is ready
    
    The first time round we maybe didn't know which files we wanted to log to.
    Suppose, for example, we had an smb.conf with
    
     log level = 1 dsdb_group_json_audit:5@/var/log/group_json.log
    
    we wouldn't see anything in "/var/log/group_json.log", while the level
    5 dsdb_group_json_audit messages would go into the main log.
    
    Note that the named file would still be opened by winbindd and others
    that use the s3 code, but would remain empty as they don't have anything
    to say about dsdb_group_json_audit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15076
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 lib/cmdline/cmdline_s4.c | 22 +++++++++++++++++-----
 lib/util/debug.c         | 27 ++++++++++++++++++---------
 lib/util/debug.h         | 10 +++++-----
 3 files changed, 40 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/cmdline/cmdline_s4.c b/lib/cmdline/cmdline_s4.c
index 29e9f34bbe2..f8be4ed670c 100644
--- a/lib/cmdline/cmdline_s4.c
+++ b/lib/cmdline/cmdline_s4.c
@@ -31,6 +31,8 @@ static bool _samba_cmdline_load_config_s4(void)
 {
 	struct loadparm_context *lp_ctx = samba_cmdline_get_lp_ctx();
 	const char *config_file = NULL;
+	const struct samba_cmdline_daemon_cfg *cmdline_daemon_cfg = \
+		samba_cmdline_get_daemon_cfg();
 	bool ok;
 
 	/* Load smb conf */
@@ -45,15 +47,11 @@ static bool _samba_cmdline_load_config_s4(void)
 	}
 
 	switch (_config_type) {
-	case SAMBA_CMDLINE_CONFIG_SERVER: {
-		const struct samba_cmdline_daemon_cfg *cmdline_daemon_cfg =
-			samba_cmdline_get_daemon_cfg();
-
+	case SAMBA_CMDLINE_CONFIG_SERVER:
 		if (!cmdline_daemon_cfg->interactive) {
 			setup_logging(getprogname(), DEBUG_FILE);
 		}
 		break;
-	}
 	default:
 		break;
 	}
@@ -70,6 +68,20 @@ static bool _samba_cmdline_load_config_s4(void)
 		}
 	}
 
+	switch (_config_type) {
+	case SAMBA_CMDLINE_CONFIG_SERVER:
+		/*
+		 * We need to setup_logging *again* to ensure multi-file
+		 * logging is set up as specified in smb.conf.
+		 */
+		if (!cmdline_daemon_cfg->interactive) {
+			setup_logging(getprogname(), DEBUG_FILE);
+		}
+		break;
+	default:
+		break;
+	}
+
 	return true;
 }
 
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 42f408736ff..8484094d014 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -1104,15 +1104,24 @@ void debug_set_hostname(const char *name)
 }
 
 /**
-  control the name of the logfile and whether logging will be to stdout, stderr
-  or a file, and set up syslog
-
-  new_log indicates the destination for the debug log (an enum in
-  order of precedence - once set to DEBUG_FILE, it is not possible to
-  reset to DEBUG_STDOUT for example.  This makes it easy to override
-  for debug to stderr on the command line, as the smb.conf cannot
-  reset it back to file-based logging
-*/
+ * Ensure debug logs are initialised.
+ *
+ * setup_logging() is called to direct logging to the correct outputs, whether
+ * those be stderr, stdout, files, or syslog, and set the program name used in
+ * the logs. It can be called multiple times.
+ *
+ * There is an order of precedence to the log type. Once set to DEBUG_FILE, it
+ * cannot be reset DEFAULT_DEBUG_STDERR, but can be set to DEBUG_STDERR, after
+ * which DEBUG_FILE is unavailable). This makes it possible to override for
+ * debug to stderr on the command line, as the smb.conf cannot reset it back
+ * to file-based logging. See enum debug_logtype.
+ *
+ * @param prog_name the program name. Directory path component will be
+ *                  ignored.
+ *
+ * @param new_logtype the requested destination for the debug log,
+ *                    as an enum debug_logtype.
+ */
 void setup_logging(const char *prog_name, enum debug_logtype new_logtype)
 {
 	debug_init();
diff --git a/lib/util/debug.h b/lib/util/debug.h
index 5f4833b0fcd..a9f3a41cde4 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -282,11 +282,11 @@ void debuglevel_set_class(size_t idx, int level);
 
 /* The following definitions come from lib/debug.c  */
 
-/** Possible destinations for the debug log (in order of precedence -
- * once set to DEBUG_FILE, it is not possible to reset to DEBUG_STDOUT
- * for example.  This makes it easy to override for debug to stderr on
- * the command line, as the smb.conf cannot reset it back to
- * file-based logging */
+/**
+ * Possible destinations for the debug log.
+ *
+ * Set via setup_logging(); higher values have precedence.
+ */
 enum debug_logtype {
 	DEBUG_DEFAULT_STDERR = 0,
 	DEBUG_DEFAULT_STDOUT = 1,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list