} state = {
.settings = {
.timestamp_logs = true
- }
+ },
+ .fd = 2 /* stderr by default */
};
/* -------------------------------------------------------------------------- **
TALLOC_FREE(format_bufr);
- debug_num_classes = DBGC_MAX_FIXED;
+ debug_num_classes = 0;
state.initialized = false;
}
int ndx;
int *new_class_list;
char **new_name_list;
+ int default_level;
if (!classname)
return -1;
new_class_list = DEBUGLEVEL_CLASS;
}
+ default_level = DEBUGLEVEL_CLASS[DBGC_ALL];
+
new_class_list = talloc_realloc(NULL, new_class_list, int, ndx + 1);
if (!new_class_list)
return -1;
DEBUGLEVEL_CLASS = new_class_list;
- DEBUGLEVEL_CLASS[ndx] = DEBUGLEVEL_CLASS[DBGC_ALL];
+ DEBUGLEVEL_CLASS[ndx] = default_level;
new_name_list = talloc_realloc(NULL, classname_table, char *, ndx + 1);
if (!new_name_list)
void debug_set_logfile(const char *name)
{
+ if (name == NULL || *name == 0) {
+ /* this copes with calls when smb.conf is not loaded yet */
+ return;
+ }
TALLOC_FREE(state.debugf);
state.debugf = talloc_strdup(NULL, name);
}
return (state.logtype == DEBUG_DEFAULT_STDERR) || (state.logtype == DEBUG_STDERR);
}
+bool debug_get_output_is_stdout(void)
+{
+ return (state.logtype == DEBUG_DEFAULT_STDOUT) || (state.logtype == DEBUG_STDOUT);
+}
+
/**************************************************************************
reopen the log files
note that we now do this unconditionally
switch (state.logtype) {
case DEBUG_STDOUT:
+ case DEBUG_DEFAULT_STDOUT:
debug_close_fd(state.fd);
state.fd = 1;
return true;
if (new_fd == -1) {
log_overflow = true;
- DEBUG(0, ("Unable to open new log file %s: %s\n", state.debugf, strerror(errno)));
+ DEBUG(0, ("Unable to open new log file '%s': %s\n", state.debugf, strerror(errno)));
log_overflow = false;
ret = false;
} else {
* loop check do a new check as root.
*/
- if( geteuid() != 0) {
+#if _SAMBA_BUILD_ == 3
+ if (geteuid() != sec_initial_uid())
+#else
+ if( geteuid() != 0)
+#endif
+ {
/* We don't check sec_initial_uid() here as it isn't
* available in common code and we don't generally
* want to rotate and the possibly lose logs in
header_str[0] = '\0';
- if( state.settings.debug_pid)
+ if (level >= 10 && state.settings.debug_pid)
slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)getpid());
- if( state.settings.debug_uid) {
+ if (level >= 10 && state.settings.debug_uid) {
size_t hs_len = strlen(header_str);
slprintf(header_str + hs_len,
sizeof(header_str) - 1 - hs_len,
(unsigned int)getuid(), (unsigned int)getgid());
}
- if (state.settings.debug_class && (cls != DBGC_ALL)) {
+ if (level >= 10 && state.settings.debug_class && (cls != DBGC_ALL)) {
size_t hs_len = strlen(header_str);
slprintf(header_str + hs_len,
sizeof(header_str) -1 - hs_len,