This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
Receive a "set debug level" message.
****************************************************************************/
-static void debug_message(int msg_type, struct process_id src,
- void *buf, size_t len, void *private_data)
+static void debug_message(struct messaging_context *msg_ctx,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id src,
+ DATA_BLOB *data)
{
- const char *params_str = (const char *)buf;
+ const char *params_str = (const char *)data->data;
/* Check, it's a proper string! */
- if (params_str[len-1] != '\0') {
+ if (params_str[(data->length)-1] != '\0') {
DEBUG(1, ("Invalid debug message from pid %u to pid %u\n",
(unsigned int)procid_to_pid(&src),
(unsigned int)getpid()));
debug_parse_levels(params_str);
}
-/****************************************************************************
- Send a "set debug level" message.
-****************************************************************************/
-
-void debug_message_send(pid_t pid, const char *params_str)
-{
- if (!params_str)
- return;
- message_send_pid(pid_to_procid(pid), MSG_DEBUG,
- params_str, strlen(params_str) + 1,
- False);
-}
-
/****************************************************************************
Return current debug level.
****************************************************************************/
-static void debuglevel_message(int msg_type, struct process_id src,
- void *buf, size_t len, void *private_data)
+static void debuglevel_message(struct messaging_context *msg_ctx,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id src,
+ DATA_BLOB *data)
{
char *message = debug_list_class_names_and_levels();
return;
}
- DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %u\n",
- (unsigned int)procid_to_pid(&src)));
- message_send_pid(src, MSG_DEBUGLEVEL, message, strlen(message) + 1, True);
+ DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %s\n",
+ procid_str_static(&src)));
+ messaging_send_buf(msg_ctx, src, MSG_DEBUGLEVEL,
+ (uint8 *)message, strlen(message) + 1);
SAFE_FREE(message);
}
initialised = True;
- message_register(MSG_DEBUG, debug_message, NULL);
- message_register(MSG_REQ_DEBUGLEVEL, debuglevel_message, NULL);
-
for(p = default_classname_table; *p; p++) {
debug_add_class(*p);
}
}
+void debug_register_msgs(struct messaging_context *msg_ctx)
+{
+ messaging_register(msg_ctx, NULL, MSG_DEBUG, debug_message);
+ messaging_register(msg_ctx, NULL, MSG_REQ_DEBUGLEVEL,
+ debuglevel_message);
+}
+
/***************************************************************************
Get ready for syslog stuff
**************************************************************************/
int maxlog;
SMB_STRUCT_STAT st;
+ /*
+ * We need to be root to check/change log-file, skip this and let the main
+ * loop check do a new check as root.
+ */
+
+ if( geteuid() != 0 )
+ return;
+
if(log_overflow || !need_to_check_log_size() )
return;
maxlog = lp_max_log_size() * 1024;
if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
-
- become_root_uid_only();
-
(void)reopen_logs();
if( dbf && get_file_size( debugf ) > maxlog ) {
pstring name;
(void)rename(name, debugf);
}
}
-
- unbecome_root_uid_only();
}
/*
/* Print it all out at once to prevent split syslog output. */
if( lp_debug_prefix_timestamp() ) {
- (void)Debug1( "[%s, %d%s] ",
+ (void)Debug1( "[%s, %2d%s] ",
current_timestring(lp_debug_hires_timestamp()), level,
header_str);
} else {