increased `make test` logging in syslog with "debug syslog format = always"

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Wed Jul 26 04:42:47 UTC 2023


So, seeing as I started this I feel like I should keep you posted.

> static void Debug1(const char *msg, size_t msg_len)
> {
> 	int old_errno = errno;
> 	enum debug_logtype logtype = state.logtype;
> 
> 	debug_count++;
> 
> 	if (state.settings.debug_syslog_format == DEBUG_SYSLOG_FORMAT_ALWAYS) {
> 		switch(state.logtype) {
> 		case DEBUG_STDOUT:
> 		case DEBUG_STDERR:
> 		case DEBUG_DEFAULT_STDOUT:
> 		case DEBUG_DEFAULT_STDERR:
> 			/* Behave the same as logging to a file */
> 			logtype = DEBUG_FILE;
> 			break;

By treating STDERR et. al. as DEBUG_FILE,...


> 		default:
> 			break;
> 		}
> 	}
> 
> 	switch(logtype) {
> 	case DEBUG_CALLBACK:
> 		debug_callback_log(msg, msg_len, current_msg_level);
> 		break;
> 	case DEBUG_STDOUT:
> 	case DEBUG_STDERR:
> 	case DEBUG_DEFAULT_STDOUT:
> 	case DEBUG_DEFAULT_STDERR:

...we skip over this straightforward write to the fd...

> 		if (dbgc_config[DBGC_ALL].fd > 0) {
> 			ssize_t ret;
> 			do {
> 				ret = write(dbgc_config[DBGC_ALL].fd,
> 					    msg,
> 					    msg_len);
> 			} while (ret == -1 && errno == EINTR);
> 		}
> 		break;
> 	case DEBUG_FILE:
> 		debug_backends_log(msg, msg_len, current_msg_level);

...and loop through all the registered backends.

When "logging" is not set in smb.conf, the default backend configuration is 
"syslog at 0 file at 1000" (via debug_set_settings), so we write to the file *and* 
syslog (the file is stderr for the Kinit messages).

I am not quite sure why the Kinit stderr messages are not showing up somewhere, 
or other messages in the same environment appear to work, but there is plenty of 
unknown left to explain those things.


> 		break;
> 	};
> 
> 	errno = old_errno;
> }
> 

Douglas




More information about the samba-technical mailing list