mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
s3-debug Impove setup_logging() to specify logging to stderr
This change improves the setup_logging() API so that callers which wish to set up logging to stderr can simply ask for it, rather than directly modify the dbf global variable. Andrew Bartlett
This commit is contained in:
parent
4ae27891f8
commit
9da4ace1d9
@ -5046,11 +5046,8 @@ static int do_message_op(struct user_auth_info *a_info)
|
||||
set_global_myname( "" );
|
||||
|
||||
/* set default debug level to 1 regardless of what smb.conf sets */
|
||||
setup_logging( "smbclient", true );
|
||||
setup_logging( "smbclient", DEBUG_DEFAULT_STDERR );
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
|
||||
if ((dbf = x_fdup(x_stderr))) {
|
||||
x_setbuf( dbf, NULL );
|
||||
}
|
||||
|
||||
load_case_tables();
|
||||
|
||||
@ -5119,10 +5116,7 @@ static int do_message_op(struct user_auth_info *a_info)
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
if (dbf) {
|
||||
x_fclose(dbf);
|
||||
}
|
||||
dbf = x_stderr;
|
||||
setup_logging("smbclient", DEBUG_STDERR );
|
||||
display_set_stderr();
|
||||
break;
|
||||
|
||||
@ -5215,7 +5209,7 @@ static int do_message_op(struct user_auth_info *a_info)
|
||||
}
|
||||
|
||||
if ( override_logfile )
|
||||
setup_logging( lp_logfile(), false );
|
||||
setup_logging( lp_logfile(), DEBUG_FILE );
|
||||
|
||||
if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true)) {
|
||||
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
|
||||
|
@ -1946,7 +1946,7 @@ int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind)
|
||||
* tar output
|
||||
*/
|
||||
if (tarhandle == 1) {
|
||||
dbf = x_stderr;
|
||||
setup_logging("smbclient", DEBUG_STDERR);
|
||||
}
|
||||
if (!argv[Optind]) {
|
||||
DEBUG(0,("Must specify tar filename\n"));
|
||||
|
@ -240,7 +240,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
* Setup the SAMBA server state...
|
||||
*/
|
||||
|
||||
setup_logging("smbspool", True);
|
||||
setup_logging("smbspool", DEBUG_STDOUT);
|
||||
|
||||
lp_set_in_client(True); /* Make sure that we tell lp_load we are */
|
||||
|
||||
|
@ -59,8 +59,6 @@ bool dbghdr( int level, const char *location, const char *func);
|
||||
#pragma mips_frequency_hint NEVER dbghdr
|
||||
#endif
|
||||
|
||||
extern XFILE *dbf;
|
||||
|
||||
/* If we have these macros, we can add additional info to the header. */
|
||||
|
||||
#ifdef HAVE_FUNCTION_MACRO
|
||||
@ -250,6 +248,13 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
|
||||
|
||||
/* The following definitions come from lib/debug.c */
|
||||
|
||||
/* Possible destinations for the debug log (in order of precedence,
|
||||
* only a higher value will override a lower value */
|
||||
enum debug_logtype {DEBUG_DEFAULT_STDERR = 0, DEBUG_STDOUT = 1, DEBUG_FILE = 2, DEBUG_STDERR = 3};
|
||||
|
||||
void setup_logging(const char *prog_name, enum debug_logtype new_logtype);
|
||||
|
||||
void debug_close_dbf(void);
|
||||
void gfree_debugsyms(void);
|
||||
const char *debug_classname_from_index(int ndx);
|
||||
int debug_add_class(const char *classname);
|
||||
@ -258,8 +263,6 @@ bool debug_parse_levels(const char *params_str);
|
||||
void debug_message(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data);
|
||||
void debug_init(void);
|
||||
void debug_register_msgs(struct messaging_context *msg_ctx);
|
||||
void setup_logging(const char *pname, bool interactive);
|
||||
void setup_logging_stdout( void );
|
||||
void debug_set_logfile(const char *name);
|
||||
bool reopen_logs( void );
|
||||
void force_check_log_size( void );
|
||||
@ -270,3 +273,4 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func);
|
||||
bool dbghdr(int level, const char *location, const char *func);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -70,16 +70,22 @@
|
||||
* a newline.
|
||||
*/
|
||||
|
||||
/* state variables for the debug system */
|
||||
static struct {
|
||||
XFILE *dbf; /* The log file handle */
|
||||
enum debug_logtype logtype; /* The type of logging we are doing: eg stdout, file, stderr */
|
||||
const char *prog_name;
|
||||
bool reopening_logs;
|
||||
} state;
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* External variables.
|
||||
*
|
||||
* dbf - Global debug file handle.
|
||||
* debugf - Debug file name.
|
||||
* DEBUGLEVEL - System-wide debug message limit. Messages with message-
|
||||
* levels higher than DEBUGLEVEL will not be processed.
|
||||
*/
|
||||
|
||||
XFILE *dbf = NULL;
|
||||
static char *debugf = NULL;
|
||||
bool debug_warn_unknown_class = True;
|
||||
bool debug_auto_add_unknown_class = True;
|
||||
@ -109,10 +115,6 @@ int DEBUGLEVEL = &debug_all_class_hack;
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Internal variables.
|
||||
*
|
||||
* stdout_logging - Default False, if set to True then dbf will be set to
|
||||
* stdout and debug output will go to dbf only, and not
|
||||
* to syslog. Set in setup_logging() and read in Debug1().
|
||||
*
|
||||
* debug_count - Number of debug messages that have been output.
|
||||
* Used to check log size.
|
||||
*
|
||||
@ -133,7 +135,6 @@ int DEBUGLEVEL = &debug_all_class_hack;
|
||||
* are unable to open a new log file for some reason.
|
||||
*/
|
||||
|
||||
static bool stdout_logging = False;
|
||||
static int debug_count = 0;
|
||||
#ifdef WITH_SYSLOG
|
||||
static int syslog_level = 0;
|
||||
@ -564,55 +565,36 @@ void debug_register_msgs(struct messaging_context *msg_ctx)
|
||||
debuglevel_message);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Get ready for syslog stuff
|
||||
**************************************************************************/
|
||||
|
||||
void setup_logging(const char *pname, bool interactive)
|
||||
/**
|
||||
control the name of the logfile and whether logging will be to stdout, stderr
|
||||
or a file, and set up syslog
|
||||
*/
|
||||
void setup_logging(const char *prog_name, enum debug_logtype new_logtype)
|
||||
{
|
||||
debug_init();
|
||||
|
||||
/* reset to allow multiple setup calls, going from interactive to
|
||||
non-interactive */
|
||||
stdout_logging = False;
|
||||
if (dbf) {
|
||||
x_fflush(dbf);
|
||||
if (dbf != x_stdout) {
|
||||
(void) x_fclose(dbf);
|
||||
}
|
||||
if (state.logtype < new_logtype) {
|
||||
state.logtype = new_logtype;
|
||||
}
|
||||
|
||||
dbf = NULL;
|
||||
|
||||
if (interactive) {
|
||||
stdout_logging = True;
|
||||
dbf = x_stdout;
|
||||
x_setbuf( x_stdout, NULL );
|
||||
if (prog_name) {
|
||||
state.prog_name = prog_name;
|
||||
}
|
||||
reopen_logs();
|
||||
|
||||
if (state.logtype == DEBUG_FILE) {
|
||||
#ifdef WITH_SYSLOG
|
||||
else {
|
||||
const char *p = strrchr_m( pname,'/' );
|
||||
const char *p = strrchr_m( prog_name,'/' );
|
||||
if (p)
|
||||
pname = p + 1;
|
||||
prog_name = p + 1;
|
||||
#ifdef LOG_DAEMON
|
||||
openlog( pname, LOG_PID, SYSLOG_FACILITY );
|
||||
openlog( prog_name, LOG_PID, SYSLOG_FACILITY );
|
||||
#else
|
||||
/* for old systems that have no facility codes. */
|
||||
openlog( pname, LOG_PID );
|
||||
openlog( prog_name, LOG_PID );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Just run logging to stdout for this program
|
||||
*/
|
||||
_PUBLIC_ void setup_logging_stdout(void)
|
||||
{
|
||||
setup_logging(NULL, True);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Set the logfile name.
|
||||
**************************************************************************/
|
||||
@ -623,6 +605,18 @@ void debug_set_logfile(const char *name)
|
||||
debugf = SMB_STRDUP(name);
|
||||
}
|
||||
|
||||
static void debug_close_xfile(XFILE *dbf)
|
||||
{
|
||||
if (dbf && (dbf != x_stderr && dbf != x_stdout)) {
|
||||
x_fclose(dbf);
|
||||
}
|
||||
}
|
||||
|
||||
void debug_close_dbf(void)
|
||||
{
|
||||
debug_close_xfile(state.dbf);
|
||||
state.dbf = NULL;
|
||||
}
|
||||
/**************************************************************************
|
||||
reopen the log files
|
||||
note that we now do this unconditionally
|
||||
@ -631,16 +625,37 @@ void debug_set_logfile(const char *name)
|
||||
Fix from dgibson@linuxcare.com.
|
||||
**************************************************************************/
|
||||
|
||||
bool reopen_logs( void )
|
||||
/**
|
||||
reopen the log file (usually called because the log file name might have changed)
|
||||
*/
|
||||
bool reopen_logs(void)
|
||||
{
|
||||
char *fname = NULL;
|
||||
mode_t oldumask;
|
||||
XFILE *new_dbf = NULL;
|
||||
XFILE *old_dbf = NULL;
|
||||
bool ret = True;
|
||||
|
||||
if (stdout_logging)
|
||||
return True;
|
||||
char *fname = NULL;
|
||||
if (state.reopening_logs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (state.logtype) {
|
||||
case DEBUG_STDOUT:
|
||||
state.dbf = x_stdout;
|
||||
x_setbuf( x_stdout, NULL );
|
||||
return true;
|
||||
|
||||
case DEBUG_DEFAULT_STDERR:
|
||||
case DEBUG_STDERR:
|
||||
debug_close_xfile(state.dbf);
|
||||
state.dbf = x_stderr;
|
||||
x_setbuf( x_stderr, NULL );
|
||||
return true;
|
||||
|
||||
case DEBUG_FILE:
|
||||
break;
|
||||
}
|
||||
|
||||
oldumask = umask( 022 );
|
||||
|
||||
@ -670,15 +685,15 @@ bool reopen_logs( void )
|
||||
log_overflow = True;
|
||||
DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno)));
|
||||
log_overflow = False;
|
||||
if (dbf)
|
||||
x_fflush(dbf);
|
||||
if (state.dbf)
|
||||
x_fflush(state.dbf);
|
||||
ret = False;
|
||||
} else {
|
||||
x_setbuf(new_dbf, NULL);
|
||||
old_dbf = dbf;
|
||||
dbf = new_dbf;
|
||||
old_dbf = state.dbf;
|
||||
state.dbf = new_dbf;
|
||||
if (old_dbf)
|
||||
(void) x_fclose(old_dbf);
|
||||
debug_close_xfile(old_dbf);
|
||||
}
|
||||
|
||||
/* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De
|
||||
@ -689,7 +704,7 @@ bool reopen_logs( void )
|
||||
(void)umask(oldumask);
|
||||
|
||||
/* Take over stderr to catch output into logs */
|
||||
if (dbf && dup2(x_fileno(dbf), 2) == -1) {
|
||||
if (state.dbf && dup2(x_fileno(state.dbf), 2) == -1) {
|
||||
close_low_fds(True); /* Close stderr too, if dup2 can't point it
|
||||
at the logfile */
|
||||
}
|
||||
@ -718,7 +733,7 @@ bool need_to_check_log_size( void )
|
||||
return( False );
|
||||
|
||||
maxlog = lp_max_log_size() * 1024;
|
||||
if( !dbf || maxlog <= 0 ) {
|
||||
if( !state.dbf || maxlog <= 0 ) {
|
||||
debug_count = 0;
|
||||
return(False);
|
||||
}
|
||||
@ -747,10 +762,10 @@ void check_log_size( void )
|
||||
|
||||
maxlog = lp_max_log_size() * 1024;
|
||||
|
||||
if(sys_fstat(x_fileno(dbf), &st, false) == 0
|
||||
if(sys_fstat(x_fileno(state.dbf), &st, false) == 0
|
||||
&& st.st_ex_size > maxlog ) {
|
||||
(void)reopen_logs();
|
||||
if( dbf && get_file_size( debugf ) > maxlog ) {
|
||||
if( state.dbf && get_file_size( debugf ) > maxlog ) {
|
||||
char *name = NULL;
|
||||
|
||||
if (asprintf(&name, "%s.old", debugf ) < 0) {
|
||||
@ -770,7 +785,7 @@ void check_log_size( void )
|
||||
* Here's where we need to panic if dbf == NULL..
|
||||
*/
|
||||
|
||||
if(dbf == NULL) {
|
||||
if(state.dbf == NULL) {
|
||||
/* This code should only be reached in very strange
|
||||
* circumstances. If we merely fail to open the new log we
|
||||
* should stick with the old one. ergo this should only be
|
||||
@ -778,8 +793,8 @@ void check_log_size( void )
|
||||
* startup or when the log level is increased from zero.
|
||||
* -dwg 6 June 2000
|
||||
*/
|
||||
dbf = x_fopen( "/dev/console", O_WRONLY, 0);
|
||||
if(dbf) {
|
||||
state.dbf = x_fopen( "/dev/console", O_WRONLY, 0);
|
||||
if(state.dbf) {
|
||||
DEBUG(0,("check_log_size: open of debug file %s failed - using console.\n",
|
||||
debugf ));
|
||||
} else {
|
||||
@ -804,10 +819,10 @@ void check_log_size( void )
|
||||
|
||||
debug_count++;
|
||||
|
||||
if( stdout_logging ) {
|
||||
if ( state.logtype != DEBUG_FILE ) {
|
||||
va_start( ap, format_str );
|
||||
if(dbf)
|
||||
(void)x_vfprintf( dbf, format_str, ap );
|
||||
if(state.dbf)
|
||||
(void)x_vfprintf( state.dbf, format_str, ap );
|
||||
va_end( ap );
|
||||
errno = old_errno;
|
||||
goto done;
|
||||
@ -822,13 +837,13 @@ void check_log_size( void )
|
||||
if( !lp_syslog_only() )
|
||||
#endif
|
||||
{
|
||||
if( !dbf ) {
|
||||
if( !state.dbf ) {
|
||||
mode_t oldumask = umask( 022 );
|
||||
|
||||
dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 );
|
||||
state.dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 );
|
||||
(void)umask( oldumask );
|
||||
if( dbf ) {
|
||||
x_setbuf( dbf, NULL );
|
||||
if( state.dbf ) {
|
||||
x_setbuf( state.dbf, NULL );
|
||||
} else {
|
||||
errno = old_errno;
|
||||
goto done;
|
||||
@ -880,11 +895,11 @@ void check_log_size( void )
|
||||
#endif
|
||||
{
|
||||
va_start( ap, format_str );
|
||||
if(dbf)
|
||||
(void)x_vfprintf( dbf, format_str, ap );
|
||||
if(state.dbf)
|
||||
(void)x_vfprintf( state.dbf, format_str, ap );
|
||||
va_end( ap );
|
||||
if(dbf)
|
||||
(void)x_fflush( dbf );
|
||||
if(state.dbf)
|
||||
(void)x_fflush( state.dbf );
|
||||
}
|
||||
|
||||
done:
|
||||
@ -926,7 +941,7 @@ static void bufr_print( void )
|
||||
static void format_debug_text( const char *msg )
|
||||
{
|
||||
size_t i;
|
||||
bool timestamp = (!stdout_logging && (lp_timestamp_logs() || !(lp_loaded())));
|
||||
bool timestamp = (state.logtype == DEBUG_FILE && (lp_timestamp_logs() || !(lp_loaded())));
|
||||
|
||||
if (!format_bufr) {
|
||||
debug_init();
|
||||
@ -970,8 +985,8 @@ static void format_debug_text( const char *msg )
|
||||
void dbgflush( void )
|
||||
{
|
||||
bufr_print();
|
||||
if(dbf)
|
||||
(void)x_fflush( dbf );
|
||||
if(state.dbf)
|
||||
(void)x_fflush( state.dbf );
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -1021,8 +1036,9 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
|
||||
#endif
|
||||
|
||||
/* Don't print a header if we're logging to stdout. */
|
||||
if( stdout_logging )
|
||||
if ( state.logtype != DEBUG_FILE ) {
|
||||
return( True );
|
||||
}
|
||||
|
||||
/* Print the header if timestamps are turned on. If parameters are
|
||||
* not yet loaded, then default to timestamps on.
|
||||
|
@ -80,11 +80,8 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
|
||||
}
|
||||
|
||||
/* prevent setup_logging() from closing x_stderr... */
|
||||
dbf = 0;
|
||||
setup_logging("libnetapi", true);
|
||||
setup_logging("libnetapi", DEBUG_STDERR);
|
||||
|
||||
dbf = x_stderr;
|
||||
x_setbuf(x_stderr, NULL);
|
||||
AllowDebugChange = false;
|
||||
|
||||
load_case_tables();
|
||||
|
@ -294,7 +294,7 @@ int main(int argc, const char **argv)
|
||||
};
|
||||
|
||||
load_case_tables();
|
||||
dbf = x_stderr;
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
/* parse options */
|
||||
pc = poptGetContext("smbconftort", argc, (const char **)argv,
|
||||
|
@ -47,7 +47,7 @@ SMBC_module_init(void * punused)
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging("libsmbclient", True);
|
||||
setup_logging("libsmbclient", DEBUG_STDOUT);
|
||||
|
||||
/* Here we would open the smb.conf file if needed ... */
|
||||
|
||||
@ -561,8 +561,7 @@ smbc_init_context(SMBCCTX *context)
|
||||
* leave it up to the user. If any one context spefies debug to
|
||||
* stderr then all will be.
|
||||
*/
|
||||
dbf = x_stderr;
|
||||
x_setbuf(x_stderr, NULL);
|
||||
setup_logging("libsmbclient", DEBUG_STDERR);
|
||||
}
|
||||
|
||||
if ((!smbc_getFunctionAuthData(context) &&
|
||||
|
@ -863,8 +863,11 @@ static bool open_sockets(bool isdaemon, int port)
|
||||
DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setup_logging( argv[0], log_stdout );
|
||||
if (log_stdout) {
|
||||
setup_logging( argv[0], DEBUG_STDOUT);
|
||||
} else {
|
||||
setup_logging( argv[0], DEBUG_FILE);
|
||||
}
|
||||
|
||||
reopen_logs();
|
||||
|
||||
@ -1024,8 +1027,8 @@ static bool open_sockets(bool isdaemon, int port)
|
||||
TALLOC_FREE(frame);
|
||||
process();
|
||||
|
||||
if (dbf)
|
||||
x_fclose(dbf);
|
||||
debug_close_dbf();
|
||||
|
||||
kill_async_dns_child();
|
||||
return(0);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
while(poptGetNextOpt(pc) != -1);
|
||||
|
||||
setup_logging(poptGetArg(pc), True);
|
||||
setup_logging(poptGetArg(pc), DEBUG_STDERR);
|
||||
|
||||
if (poptPeekArg(pc)) {
|
||||
config_file = poptGetArg(pc);
|
||||
@ -61,7 +61,6 @@ int main(int argc, const char **argv)
|
||||
count = atoi(count_str);
|
||||
}
|
||||
|
||||
dbf = x_stderr;
|
||||
/* Don't let the debuglevel be changed by smb.conf. */
|
||||
AllowDebugChange = False;
|
||||
|
||||
|
@ -912,7 +912,7 @@ out_free:
|
||||
|
||||
/* the following functions are part of the Samba debugging
|
||||
facilities. See lib/debug.c */
|
||||
setup_logging("rpcclient", True);
|
||||
setup_logging("rpcclient", DEBUG_STDOUT);
|
||||
|
||||
rpcclient_auth_info = user_auth_info_init(frame);
|
||||
if (rpcclient_auth_info == NULL) {
|
||||
|
@ -915,7 +915,11 @@ extern void build_options(bool screen);
|
||||
log_stdout = True;
|
||||
}
|
||||
|
||||
setup_logging(argv[0],log_stdout);
|
||||
if (log_stdout) {
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
} else {
|
||||
setup_logging(argv[0], DEBUG_FILE);
|
||||
}
|
||||
|
||||
if (print_build_options) {
|
||||
build_options(True); /* Display output to screen as well as debug */
|
||||
|
@ -604,14 +604,12 @@ static void usage(void)
|
||||
|
||||
load_case_tables();
|
||||
|
||||
dbf = x_stderr;
|
||||
|
||||
if (argc < 3 || argv[1][0] == '-') {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
for (server=0;server<NSERVERS;server++) {
|
||||
share[server] = argv[1+server];
|
||||
|
@ -491,13 +491,13 @@ static void usage(void)
|
||||
|
||||
setlinebuf(stdout);
|
||||
|
||||
dbf = x_stderr;
|
||||
|
||||
if (argc < 5 || argv[1][0] == '-') {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
share1 = argv[1];
|
||||
share2 = argv[2];
|
||||
nfspath1 = argv[3];
|
||||
@ -506,8 +506,6 @@ static void usage(void)
|
||||
all_string_sub(share1,"/","\\",0);
|
||||
all_string_sub(share2,"/","\\",0);
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
|
||||
argc -= 4;
|
||||
argv += 4;
|
||||
|
||||
|
@ -484,8 +484,6 @@ static void usage(void)
|
||||
|
||||
setlinebuf(stdout);
|
||||
|
||||
dbf = x_stderr;
|
||||
|
||||
DEBUGLEVEL = 0;
|
||||
AllowDebugChange = False;
|
||||
|
||||
@ -498,7 +496,7 @@ static void usage(void)
|
||||
|
||||
all_string_sub(share,"/","\\",0);
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
argc -= 1;
|
||||
argv += 1;
|
||||
|
@ -49,7 +49,7 @@ static void pong_message(struct messaging_context *msg_ctx,
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
|
||||
|
||||
|
@ -259,7 +259,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Load configuration */
|
||||
lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
|
||||
setup_logging("pdbtest", True);
|
||||
setup_logging("pdbtest", DEBUG_STDOUT);
|
||||
|
||||
if (backend == NULL) {
|
||||
backend = lp_passdb_backend();
|
||||
|
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* the following functions are part of the Samba debugging
|
||||
facilities. See lib/debug.c */
|
||||
setup_logging("smbiconv", True);
|
||||
setup_logging("smbiconv", DEBUG_STDOUT);
|
||||
|
||||
if (preload_modules[0]) smb_load_modules(preload_modules);
|
||||
|
||||
|
@ -7937,15 +7937,13 @@ static void usage(void)
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
int seed = time(NULL);
|
||||
|
||||
dbf = x_stdout;
|
||||
|
||||
#ifdef HAVE_SETBUFFER
|
||||
setbuffer(stdout, NULL, 0);
|
||||
#endif
|
||||
|
||||
load_case_tables();
|
||||
setup_logging("smbtorture", DEBUG_STDOUT);
|
||||
|
||||
setup_logging("smbtorture", true);
|
||||
load_case_tables();
|
||||
|
||||
if (is_default_dyn_CONFIGFILE()) {
|
||||
if(getenv("SMB_CONF_PATH")) {
|
||||
|
@ -462,7 +462,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* the following functions are part of the Samba debugging
|
||||
facilities. See lib/debug.c */
|
||||
setup_logging("vfstest", True);
|
||||
setup_logging("vfstest", DEBUG_STDOUT);
|
||||
|
||||
/* Load command lists */
|
||||
|
||||
|
@ -215,7 +215,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
load_case_tables();
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
|
||||
dbf = x_stderr;
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
AllowDebugChange = false;
|
||||
lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
|
||||
|
||||
|
@ -258,6 +258,7 @@ int main(int argc, const char *argv[])
|
||||
setlinebuf(stdout);
|
||||
}
|
||||
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
|
||||
|
||||
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
|
||||
@ -279,7 +280,6 @@ int main(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
load_case_tables();
|
||||
dbf = x_stderr;
|
||||
AllowDebugChange = false;
|
||||
lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
|
||||
|
||||
|
@ -822,6 +822,8 @@ static struct functable net_func[] = {
|
||||
|
||||
zero_sockaddr(&c->opt_dest_ip);
|
||||
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
@ -834,7 +836,6 @@ static struct functable net_func[] = {
|
||||
|
||||
/* set default debug level to 0 regardless of what smb.conf sets */
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
|
||||
dbf = x_stderr;
|
||||
c->private_data = net_func;
|
||||
|
||||
pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
|
||||
|
@ -259,7 +259,7 @@ int main(int argc,char *argv[])
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
pc = poptGetContext("nmblookup", argc, (const char **)argv,
|
||||
long_options, POPT_CONTEXT_KEEP_FIRST);
|
||||
|
@ -2557,7 +2557,7 @@ enum {
|
||||
/* Samba client initialisation */
|
||||
load_case_tables();
|
||||
|
||||
dbf = x_stderr;
|
||||
setup_logging("ntlm_auth", DEBUG_STDERR);
|
||||
|
||||
/* Parse options */
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ int main (int argc, char **argv)
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging("pdbedit", True);
|
||||
setup_logging("pdbedit", DEBUG_STDOUT);
|
||||
|
||||
pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
|
||||
POPT_CONTEXT_KEEP_FIRST);
|
||||
|
@ -215,9 +215,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
/* setup logging options */
|
||||
|
||||
setup_logging( "profiles", True );
|
||||
dbf = x_stderr;
|
||||
x_setbuf( x_stderr, NULL );
|
||||
setup_logging( "profiles", DEBUG_STDERR);
|
||||
|
||||
pc = poptGetContext("profiles", argc, (const char **)argv, long_options,
|
||||
POPT_CONTEXT_KEEP_FIRST);
|
||||
|
@ -543,10 +543,8 @@ int main(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
/* set default debug level to 1 regardless of what smb.conf sets */
|
||||
setup_logging( "sharesec", True );
|
||||
setup_logging( "sharesec", DEBUG_STDERR);
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
|
||||
dbf = x_stderr;
|
||||
x_setbuf( x_stderr, NULL );
|
||||
|
||||
pc = poptGetContext("sharesec", argc, argv, long_options, 0);
|
||||
|
||||
|
@ -1203,10 +1203,8 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info,
|
||||
|
||||
|
||||
/* set default debug level to 1 regardless of what smb.conf sets */
|
||||
setup_logging( "smbcacls", True );
|
||||
setup_logging( "smbcacls", DEBUG_STDERR);
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
|
||||
dbf = x_stderr;
|
||||
x_setbuf( x_stderr, NULL );
|
||||
AllowDebugChange = false;
|
||||
|
||||
setlinebuf(stdout);
|
||||
|
@ -1379,7 +1379,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
/* Parse command line arguments using popt */
|
||||
|
||||
|
@ -464,10 +464,8 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
|
||||
ZERO_STRUCT(qt);
|
||||
|
||||
/* set default debug level to 1 regardless of what smb.conf sets */
|
||||
setup_logging( "smbcquotas", True );
|
||||
setup_logging( "smbcquotas", DEBUG_STDERR);
|
||||
DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
|
||||
dbf = x_stderr;
|
||||
x_setbuf( x_stderr, NULL );
|
||||
|
||||
setlinebuf(stdout);
|
||||
|
||||
|
@ -295,7 +295,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
configfile = get_dyn_CONFIGFILE();
|
||||
|
||||
|
@ -584,7 +584,7 @@ int main(int argc, char **argv)
|
||||
|
||||
local_flags = process_options(argc, argv, local_flags);
|
||||
|
||||
setup_logging("smbpasswd", True);
|
||||
setup_logging("smbpasswd", DEBUG_STDERR);
|
||||
|
||||
/*
|
||||
* Set the machine NETBIOS name if not already
|
||||
|
@ -291,9 +291,7 @@ static bool print_tree(struct user_auth_info *user_info)
|
||||
|
||||
setlinebuf(stdout);
|
||||
|
||||
dbf = x_stderr;
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
auth_info = user_auth_info_init(frame);
|
||||
if (auth_info == NULL) {
|
||||
|
@ -50,7 +50,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
while(poptGetNextOpt(pc) != -1);
|
||||
|
||||
setup_logging(poptGetArg(pc), true);
|
||||
setup_logging(poptGetArg(pc), DEBUG_STDERR);
|
||||
|
||||
sequence = poptGetArg(pc);
|
||||
|
||||
@ -59,7 +59,6 @@ int main(int argc, const char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
dbf = x_stderr;
|
||||
DEBUGLEVEL = 0;
|
||||
AllowDebugChange = false;
|
||||
|
||||
|
@ -309,9 +309,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
|
||||
sec_init();
|
||||
load_case_tables();
|
||||
|
||||
setup_logging(argv[0],True);
|
||||
|
||||
dbf = x_stderr;
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
if (getuid() != geteuid()) {
|
||||
d_printf("smbstatus should not be run setuid\n");
|
||||
|
@ -365,7 +365,7 @@ rameter is ignored when using CUPS libraries.\n",
|
||||
exit(0);
|
||||
}
|
||||
|
||||
setup_logging(poptGetArg(pc), True);
|
||||
setup_logging(poptGetArg(pc), DEBUG_STDERR);
|
||||
|
||||
if (poptPeekArg(pc))
|
||||
config_file = poptGetArg(pc);
|
||||
@ -381,7 +381,6 @@ rameter is ignored when using CUPS libraries.\n",
|
||||
goto done;
|
||||
}
|
||||
|
||||
dbf = x_stderr;
|
||||
/* Don't let the debuglevel be changed by smb.conf. */
|
||||
AllowDebugChange = False;
|
||||
|
||||
|
@ -1413,12 +1413,12 @@ const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid)
|
||||
/* we don't want any SIGPIPE messages */
|
||||
BlockSignals(True,SIGPIPE);
|
||||
|
||||
dbf = x_fopen("/dev/null", O_WRONLY, 0);
|
||||
if (!dbf) dbf = x_stderr;
|
||||
debug_set_logfile("/dev/null");
|
||||
|
||||
/* we don't want stderr screwing us up */
|
||||
close(2);
|
||||
open("/dev/null", O_WRONLY);
|
||||
setup_logging("swat", DEBUG_FILE);
|
||||
|
||||
pc = poptGetContext("swat", argc, (const char **) argv, long_options, 0);
|
||||
|
||||
@ -1429,9 +1429,10 @@ const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid)
|
||||
poptFreeContext(pc);
|
||||
|
||||
load_case_tables();
|
||||
|
||||
setup_logging(argv[0],False);
|
||||
|
||||
/* This should set a more apporiate log file */
|
||||
load_config(True);
|
||||
reopen_logs();
|
||||
load_interfaces();
|
||||
iNumNonAutoPrintServices = lp_numservices();
|
||||
load_printers(server_event_context(), server_messaging_context());
|
||||
|
@ -1217,7 +1217,11 @@ int main(int argc, char **argv, char **envp)
|
||||
SAFE_FREE(lfile);
|
||||
}
|
||||
}
|
||||
setup_logging("winbindd", log_stdout);
|
||||
if (log_stdout) {
|
||||
setup_logging("winbindd", DEBUG_STDOUT);
|
||||
} else {
|
||||
setup_logging("winbindd", DEBUG_FILE);
|
||||
}
|
||||
reopen_logs();
|
||||
|
||||
DEBUG(0,("winbindd version %s started.\n", samba_version_string()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user